{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "ff9b812e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "#设置列不限制数量\n",
    "pd.set_option('display.max_columns', None)\n",
    "# pd.set_option('display.max_rows',None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "c21e80a2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Encoding: ascii, Confidence: 1.0\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "<>:10: SyntaxWarning: invalid escape sequence '\\p'\n",
      "<>:10: SyntaxWarning: invalid escape sequence '\\p'\n",
      "C:\\Users\\13980\\AppData\\Local\\Temp\\ipykernel_124840\\3782175784.py:10: SyntaxWarning: invalid escape sequence '\\p'\n",
      "  file_path = 'D:\\python course/000001.csv'# 添加文件路径\n"
     ]
    }
   ],
   "source": [
    "import chardet\n",
    "\n",
    "def check_encoding(filename):\n",
    "    rawdata = open(filename, 'rb').read()\n",
    "    result = chardet.detect(rawdata)\n",
    "    encoding = result['encoding']\n",
    "    confidence = result['confidence']\n",
    "    return encoding, confidence\n",
    "\n",
    "file_path = 'D:\\python course/000001.csv'# 添加文件路径\n",
    "encoding, confidence = check_encoding(file_path)\n",
    "print(f\"Encoding: {encoding}, Confidence: {confidence}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "e87b741b",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "<>:2: SyntaxWarning: invalid escape sequence '\\p'\n",
      "<>:2: SyntaxWarning: invalid escape sequence '\\p'\n",
      "C:\\Users\\13980\\AppData\\Local\\Temp\\ipykernel_124840\\1695739379.py:2: SyntaxWarning: invalid escape sequence '\\p'\n",
      "  data = pd.read_csv('D:\\python course/000001.csv') # 这一句是导入CSV文件的命令\n"
     ]
    },
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "Day",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Preclose",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Open",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Highest",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Lowest",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Close",
         "rawType": "float64",
         "type": "float"
        }
       ],
       "ref": "7b56a33a-a7f3-459d-b26e-11820235ef00",
       "rows": [
        [
         "0",
         "1990/12/19",
         "        ",
         "96.05",
         "99.98",
         "95.79",
         "99.98"
        ],
        [
         "1",
         "1990/12/20",
         "99.98",
         "104.3",
         "104.39",
         "99.98",
         "104.39"
        ],
        [
         "2",
         "1990/12/21",
         "104.39",
         "109.07",
         "109.13",
         "103.73",
         "109.13"
        ],
        [
         "3",
         "1990/12/24",
         "109.13",
         "113.57",
         "114.55",
         "109.13",
         "114.55"
        ],
        [
         "4",
         "1990/12/25",
         "114.55",
         "120.09",
         "120.25",
         "114.55",
         "120.25"
        ],
        [
         "5",
         "1990/12/26",
         "120.25",
         "125.27",
         "125.27",
         "120.25",
         "125.27"
        ],
        [
         "6",
         "1990/12/27",
         "125.27",
         "125.27",
         "125.28",
         "125.27",
         "125.28"
        ],
        [
         "7",
         "1990/12/28",
         "125.28",
         "126.39",
         "126.45",
         "125.28",
         "126.45"
        ],
        [
         "8",
         "1990/12/31",
         "126.45",
         "126.56",
         "127.61",
         "126.48",
         "127.61"
        ],
        [
         "9",
         "1991/1/2",
         "127.61",
         "127.61",
         "128.84",
         "127.61",
         "128.84"
        ],
        [
         "10",
         "1991/1/3",
         "128.84",
         "128.84",
         "130.14",
         "128.84",
         "130.14"
        ],
        [
         "11",
         "1991/1/4",
         "130.14",
         "131.27",
         "131.44",
         "130.14",
         "131.44"
        ],
        [
         "12",
         "1991/1/7",
         "131.44",
         "131.99",
         "132.06",
         "131.45",
         "132.06"
        ],
        [
         "13",
         "1991/1/8",
         "132.06",
         "132.62",
         "132.68",
         "132.06",
         "132.68"
        ],
        [
         "14",
         "1991/1/9",
         "132.68",
         "133.3",
         "133.34",
         "132.68",
         "133.34"
        ],
        [
         "15",
         "1991/1/10",
         "133.34",
         "133.93",
         "133.97",
         "133.34",
         "133.97"
        ],
        [
         "16",
         "1991/1/11",
         "133.97",
         "134.61",
         "134.61",
         "134.51",
         "134.6"
        ],
        [
         "17",
         "1991/1/14",
         "134.6",
         "134.11",
         "135.19",
         "134.11",
         "134.67"
        ],
        [
         "18",
         "1991/1/15",
         "134.67",
         "134.21",
         "134.74",
         "134.19",
         "134.74"
        ],
        [
         "19",
         "1991/1/16",
         "134.74",
         "134.19",
         "134.74",
         "134.14",
         "134.24"
        ],
        [
         "20",
         "1991/1/17",
         "134.24",
         "133.67",
         "134.25",
         "133.65",
         "134.25"
        ],
        [
         "21",
         "1991/1/18",
         "134.25",
         "133.7",
         "134.25",
         "133.67",
         "134.24"
        ],
        [
         "22",
         "1991/1/21",
         "134.24",
         "133.7",
         "134.24",
         "133.66",
         "134.24"
        ],
        [
         "23",
         "1991/1/22",
         "134.24",
         "133.72",
         "134.24",
         "133.66",
         "133.72"
        ],
        [
         "24",
         "1991/1/23",
         "133.72",
         "133.17",
         "133.72",
         "133.14",
         "133.17"
        ],
        [
         "25",
         "1991/1/24",
         "133.17",
         "132.61",
         "133.17",
         "132.57",
         "132.61"
        ],
        [
         "26",
         "1991/1/25",
         "132.61",
         "132.05",
         "132.07",
         "132.03",
         "132.05"
        ],
        [
         "27",
         "1991/1/28",
         "132.05",
         "131.46",
         "131.55",
         "131.46",
         "131.46"
        ],
        [
         "28",
         "1991/1/29",
         "131.46",
         "130.95",
         "130.97",
         "130.95",
         "130.95"
        ],
        [
         "29",
         "1991/1/30",
         "130.95",
         "130.44",
         "130.95",
         "130.41",
         "130.44"
        ],
        [
         "30",
         "1991/1/31",
         "130.44",
         "129.93",
         "130.46",
         "129.93",
         "129.97"
        ],
        [
         "31",
         "1991/2/1",
         "129.97",
         "129.5",
         "129.97",
         "129.45",
         "129.51"
        ],
        [
         "32",
         "1991/2/4",
         "129.51",
         "129.05",
         "129.58",
         "129.05",
         "129.05"
        ],
        [
         "33",
         "1991/2/5",
         "129.05",
         "128.56",
         "128.58",
         "128.53",
         "128.58"
        ],
        [
         "34",
         "1991/2/6",
         "128.58",
         "129.13",
         "129.15",
         "128.06",
         "129.14"
        ],
        [
         "35",
         "1991/2/7",
         "129.14",
         "129.74",
         "129.79",
         "129.14",
         "129.79"
        ],
        [
         "36",
         "1991/2/8",
         "129.79",
         "130.36",
         "130.39",
         "129.79",
         "130.38"
        ],
        [
         "37",
         "1991/2/11",
         "130.38",
         "130.92",
         "130.97",
         "130.39",
         "130.97"
        ],
        [
         "38",
         "1991/2/12",
         "130.97",
         "131.54",
         "131.56",
         "130.97",
         "131.35"
        ],
        [
         "39",
         "1991/2/13",
         "131.35",
         "131.93",
         "131.93",
         "131.35",
         "131.92"
        ],
        [
         "40",
         "1991/2/14",
         "131.92",
         "132.53",
         "132.53",
         "132.3",
         "132.53"
        ],
        [
         "41",
         "1991/2/19",
         "132.53",
         "133.12",
         "133.14",
         "133.08",
         "133.13"
        ],
        [
         "42",
         "1991/2/20",
         "133.13",
         "133.63",
         "133.67",
         "133.13",
         "133.67"
        ],
        [
         "43",
         "1991/2/21",
         "133.67",
         "134.24",
         "134.28",
         "133.67",
         "134.28"
        ],
        [
         "44",
         "1991/2/22",
         "134.28",
         "134.85",
         "134.87",
         "134.28",
         "134.87"
        ],
        [
         "45",
         "1991/2/25",
         "134.87",
         "134.37",
         "134.87",
         "134.33",
         "134.4"
        ],
        [
         "46",
         "1991/2/26",
         "134.4",
         "133.9",
         "134.44",
         "133.9",
         "133.93"
        ],
        [
         "47",
         "1991/2/27",
         "133.93",
         "133.44",
         "133.98",
         "133.44",
         "133.47"
        ],
        [
         "48",
         "1991/2/28",
         "133.47",
         "132.99",
         "133.52",
         "132.98",
         "133.01"
        ],
        [
         "49",
         "1991/3/1",
         "133.01",
         "132.53",
         "132.53",
         "132.47",
         "132.53"
        ]
       ],
       "shape": {
        "columns": 6,
        "rows": 8473
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Day</th>\n",
       "      <th>Preclose</th>\n",
       "      <th>Open</th>\n",
       "      <th>Highest</th>\n",
       "      <th>Lowest</th>\n",
       "      <th>Close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1990/12/19</td>\n",
       "      <td></td>\n",
       "      <td>96.050</td>\n",
       "      <td>99.980</td>\n",
       "      <td>95.790</td>\n",
       "      <td>99.980</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1990/12/20</td>\n",
       "      <td>99.98</td>\n",
       "      <td>104.300</td>\n",
       "      <td>104.390</td>\n",
       "      <td>99.980</td>\n",
       "      <td>104.390</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1990/12/21</td>\n",
       "      <td>104.39</td>\n",
       "      <td>109.070</td>\n",
       "      <td>109.130</td>\n",
       "      <td>103.730</td>\n",
       "      <td>109.130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1990/12/24</td>\n",
       "      <td>109.13</td>\n",
       "      <td>113.570</td>\n",
       "      <td>114.550</td>\n",
       "      <td>109.130</td>\n",
       "      <td>114.550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1990/12/25</td>\n",
       "      <td>114.55</td>\n",
       "      <td>120.090</td>\n",
       "      <td>120.250</td>\n",
       "      <td>114.550</td>\n",
       "      <td>120.250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8468</th>\n",
       "      <td>2025/8/25</td>\n",
       "      <td>3825.759</td>\n",
       "      <td>3848.163</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3839.972</td>\n",
       "      <td>3883.562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8469</th>\n",
       "      <td>2025/8/26</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3871.471</td>\n",
       "      <td>3888.599</td>\n",
       "      <td>3859.758</td>\n",
       "      <td>3868.382</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8470</th>\n",
       "      <td>2025/8/27</td>\n",
       "      <td>3868.382</td>\n",
       "      <td>3869.612</td>\n",
       "      <td>3887.198</td>\n",
       "      <td>3800.350</td>\n",
       "      <td>3800.350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8471</th>\n",
       "      <td>2025/8/28</td>\n",
       "      <td>3800.35</td>\n",
       "      <td>3796.711</td>\n",
       "      <td>3845.087</td>\n",
       "      <td>3761.422</td>\n",
       "      <td>3843.597</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8472</th>\n",
       "      <td>2025/8/29</td>\n",
       "      <td>3843.597</td>\n",
       "      <td>3842.823</td>\n",
       "      <td>3867.606</td>\n",
       "      <td>3839.206</td>\n",
       "      <td>3857.927</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8473 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             Day  Preclose      Open   Highest    Lowest     Close\n",
       "0     1990/12/19              96.050    99.980    95.790    99.980\n",
       "1     1990/12/20     99.98   104.300   104.390    99.980   104.390\n",
       "2     1990/12/21    104.39   109.070   109.130   103.730   109.130\n",
       "3     1990/12/24    109.13   113.570   114.550   109.130   114.550\n",
       "4     1990/12/25    114.55   120.090   120.250   114.550   120.250\n",
       "...          ...       ...       ...       ...       ...       ...\n",
       "8468   2025/8/25  3825.759  3848.163  3883.562  3839.972  3883.562\n",
       "8469   2025/8/26  3883.562  3871.471  3888.599  3859.758  3868.382\n",
       "8470   2025/8/27  3868.382  3869.612  3887.198  3800.350  3800.350\n",
       "8471   2025/8/28   3800.35  3796.711  3845.087  3761.422  3843.597\n",
       "8472   2025/8/29  3843.597  3842.823  3867.606  3839.206  3857.927\n",
       "\n",
       "[8473 rows x 6 columns]"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 本单元格是导入数据的代码\n",
    "data = pd.read_csv('D:\\python course/000001.csv') # 这一句是导入CSV文件的命令\n",
    "data # 让我看看数据是什么样子"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "783efdd7",
   "metadata": {},
   "outputs": [],
   "source": [
    "from IPython.core.interactiveshell import InteractiveShell  # 导入Jupyter交互式Shell的核心模块\n",
    "\n",
    "# 设置Jupyter Notebook的输出模式为'all'，这样每个单元格中所有语句的结果都会被依次输出（默认只输出最后一个表达式的结果）\n",
    "InteractiveShell.ast_node_interactivity = 'all'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "170e179b",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "<>:1: SyntaxWarning: invalid escape sequence '\\p'\n",
      "<>:1: SyntaxWarning: invalid escape sequence '\\p'\n",
      "C:\\Users\\13980\\AppData\\Local\\Temp\\ipykernel_124840\\1081611042.py:1: SyntaxWarning: invalid escape sequence '\\p'\n",
      "  data = pd.read_csv('D:\\python course/000001.csv') # 这一句是导入CSV文件的命令\n"
     ]
    },
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "Day",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Preclose",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Open",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Highest",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Lowest",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Close",
         "rawType": "float64",
         "type": "float"
        }
       ],
       "ref": "6180514b-54cb-4cd6-8b99-56c5a9e7bb1f",
       "rows": [
        [
         "0",
         "1990/12/19",
         "        ",
         "96.05",
         "99.98",
         "95.79",
         "99.98"
        ],
        [
         "1",
         "1990/12/20",
         "99.98",
         "104.3",
         "104.39",
         "99.98",
         "104.39"
        ],
        [
         "2",
         "1990/12/21",
         "104.39",
         "109.07",
         "109.13",
         "103.73",
         "109.13"
        ],
        [
         "3",
         "1990/12/24",
         "109.13",
         "113.57",
         "114.55",
         "109.13",
         "114.55"
        ],
        [
         "4",
         "1990/12/25",
         "114.55",
         "120.09",
         "120.25",
         "114.55",
         "120.25"
        ],
        [
         "5",
         "1990/12/26",
         "120.25",
         "125.27",
         "125.27",
         "120.25",
         "125.27"
        ],
        [
         "6",
         "1990/12/27",
         "125.27",
         "125.27",
         "125.28",
         "125.27",
         "125.28"
        ],
        [
         "7",
         "1990/12/28",
         "125.28",
         "126.39",
         "126.45",
         "125.28",
         "126.45"
        ],
        [
         "8",
         "1990/12/31",
         "126.45",
         "126.56",
         "127.61",
         "126.48",
         "127.61"
        ],
        [
         "9",
         "1991/1/2",
         "127.61",
         "127.61",
         "128.84",
         "127.61",
         "128.84"
        ],
        [
         "10",
         "1991/1/3",
         "128.84",
         "128.84",
         "130.14",
         "128.84",
         "130.14"
        ],
        [
         "11",
         "1991/1/4",
         "130.14",
         "131.27",
         "131.44",
         "130.14",
         "131.44"
        ],
        [
         "12",
         "1991/1/7",
         "131.44",
         "131.99",
         "132.06",
         "131.45",
         "132.06"
        ],
        [
         "13",
         "1991/1/8",
         "132.06",
         "132.62",
         "132.68",
         "132.06",
         "132.68"
        ],
        [
         "14",
         "1991/1/9",
         "132.68",
         "133.3",
         "133.34",
         "132.68",
         "133.34"
        ],
        [
         "15",
         "1991/1/10",
         "133.34",
         "133.93",
         "133.97",
         "133.34",
         "133.97"
        ],
        [
         "16",
         "1991/1/11",
         "133.97",
         "134.61",
         "134.61",
         "134.51",
         "134.6"
        ],
        [
         "17",
         "1991/1/14",
         "134.6",
         "134.11",
         "135.19",
         "134.11",
         "134.67"
        ],
        [
         "18",
         "1991/1/15",
         "134.67",
         "134.21",
         "134.74",
         "134.19",
         "134.74"
        ],
        [
         "19",
         "1991/1/16",
         "134.74",
         "134.19",
         "134.74",
         "134.14",
         "134.24"
        ],
        [
         "20",
         "1991/1/17",
         "134.24",
         "133.67",
         "134.25",
         "133.65",
         "134.25"
        ],
        [
         "21",
         "1991/1/18",
         "134.25",
         "133.7",
         "134.25",
         "133.67",
         "134.24"
        ],
        [
         "22",
         "1991/1/21",
         "134.24",
         "133.7",
         "134.24",
         "133.66",
         "134.24"
        ],
        [
         "23",
         "1991/1/22",
         "134.24",
         "133.72",
         "134.24",
         "133.66",
         "133.72"
        ],
        [
         "24",
         "1991/1/23",
         "133.72",
         "133.17",
         "133.72",
         "133.14",
         "133.17"
        ],
        [
         "25",
         "1991/1/24",
         "133.17",
         "132.61",
         "133.17",
         "132.57",
         "132.61"
        ],
        [
         "26",
         "1991/1/25",
         "132.61",
         "132.05",
         "132.07",
         "132.03",
         "132.05"
        ],
        [
         "27",
         "1991/1/28",
         "132.05",
         "131.46",
         "131.55",
         "131.46",
         "131.46"
        ],
        [
         "28",
         "1991/1/29",
         "131.46",
         "130.95",
         "130.97",
         "130.95",
         "130.95"
        ],
        [
         "29",
         "1991/1/30",
         "130.95",
         "130.44",
         "130.95",
         "130.41",
         "130.44"
        ],
        [
         "30",
         "1991/1/31",
         "130.44",
         "129.93",
         "130.46",
         "129.93",
         "129.97"
        ],
        [
         "31",
         "1991/2/1",
         "129.97",
         "129.5",
         "129.97",
         "129.45",
         "129.51"
        ],
        [
         "32",
         "1991/2/4",
         "129.51",
         "129.05",
         "129.58",
         "129.05",
         "129.05"
        ],
        [
         "33",
         "1991/2/5",
         "129.05",
         "128.56",
         "128.58",
         "128.53",
         "128.58"
        ],
        [
         "34",
         "1991/2/6",
         "128.58",
         "129.13",
         "129.15",
         "128.06",
         "129.14"
        ],
        [
         "35",
         "1991/2/7",
         "129.14",
         "129.74",
         "129.79",
         "129.14",
         "129.79"
        ],
        [
         "36",
         "1991/2/8",
         "129.79",
         "130.36",
         "130.39",
         "129.79",
         "130.38"
        ],
        [
         "37",
         "1991/2/11",
         "130.38",
         "130.92",
         "130.97",
         "130.39",
         "130.97"
        ],
        [
         "38",
         "1991/2/12",
         "130.97",
         "131.54",
         "131.56",
         "130.97",
         "131.35"
        ],
        [
         "39",
         "1991/2/13",
         "131.35",
         "131.93",
         "131.93",
         "131.35",
         "131.92"
        ],
        [
         "40",
         "1991/2/14",
         "131.92",
         "132.53",
         "132.53",
         "132.3",
         "132.53"
        ],
        [
         "41",
         "1991/2/19",
         "132.53",
         "133.12",
         "133.14",
         "133.08",
         "133.13"
        ],
        [
         "42",
         "1991/2/20",
         "133.13",
         "133.63",
         "133.67",
         "133.13",
         "133.67"
        ],
        [
         "43",
         "1991/2/21",
         "133.67",
         "134.24",
         "134.28",
         "133.67",
         "134.28"
        ],
        [
         "44",
         "1991/2/22",
         "134.28",
         "134.85",
         "134.87",
         "134.28",
         "134.87"
        ],
        [
         "45",
         "1991/2/25",
         "134.87",
         "134.37",
         "134.87",
         "134.33",
         "134.4"
        ],
        [
         "46",
         "1991/2/26",
         "134.4",
         "133.9",
         "134.44",
         "133.9",
         "133.93"
        ],
        [
         "47",
         "1991/2/27",
         "133.93",
         "133.44",
         "133.98",
         "133.44",
         "133.47"
        ],
        [
         "48",
         "1991/2/28",
         "133.47",
         "132.99",
         "133.52",
         "132.98",
         "133.01"
        ],
        [
         "49",
         "1991/3/1",
         "133.01",
         "132.53",
         "132.53",
         "132.47",
         "132.53"
        ]
       ],
       "shape": {
        "columns": 6,
        "rows": 8473
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Day</th>\n",
       "      <th>Preclose</th>\n",
       "      <th>Open</th>\n",
       "      <th>Highest</th>\n",
       "      <th>Lowest</th>\n",
       "      <th>Close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1990/12/19</td>\n",
       "      <td></td>\n",
       "      <td>96.050</td>\n",
       "      <td>99.980</td>\n",
       "      <td>95.790</td>\n",
       "      <td>99.980</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1990/12/20</td>\n",
       "      <td>99.98</td>\n",
       "      <td>104.300</td>\n",
       "      <td>104.390</td>\n",
       "      <td>99.980</td>\n",
       "      <td>104.390</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1990/12/21</td>\n",
       "      <td>104.39</td>\n",
       "      <td>109.070</td>\n",
       "      <td>109.130</td>\n",
       "      <td>103.730</td>\n",
       "      <td>109.130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1990/12/24</td>\n",
       "      <td>109.13</td>\n",
       "      <td>113.570</td>\n",
       "      <td>114.550</td>\n",
       "      <td>109.130</td>\n",
       "      <td>114.550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1990/12/25</td>\n",
       "      <td>114.55</td>\n",
       "      <td>120.090</td>\n",
       "      <td>120.250</td>\n",
       "      <td>114.550</td>\n",
       "      <td>120.250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8468</th>\n",
       "      <td>2025/8/25</td>\n",
       "      <td>3825.759</td>\n",
       "      <td>3848.163</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3839.972</td>\n",
       "      <td>3883.562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8469</th>\n",
       "      <td>2025/8/26</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3871.471</td>\n",
       "      <td>3888.599</td>\n",
       "      <td>3859.758</td>\n",
       "      <td>3868.382</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8470</th>\n",
       "      <td>2025/8/27</td>\n",
       "      <td>3868.382</td>\n",
       "      <td>3869.612</td>\n",
       "      <td>3887.198</td>\n",
       "      <td>3800.350</td>\n",
       "      <td>3800.350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8471</th>\n",
       "      <td>2025/8/28</td>\n",
       "      <td>3800.35</td>\n",
       "      <td>3796.711</td>\n",
       "      <td>3845.087</td>\n",
       "      <td>3761.422</td>\n",
       "      <td>3843.597</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8472</th>\n",
       "      <td>2025/8/29</td>\n",
       "      <td>3843.597</td>\n",
       "      <td>3842.823</td>\n",
       "      <td>3867.606</td>\n",
       "      <td>3839.206</td>\n",
       "      <td>3857.927</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8473 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             Day  Preclose      Open   Highest    Lowest     Close\n",
       "0     1990/12/19              96.050    99.980    95.790    99.980\n",
       "1     1990/12/20     99.98   104.300   104.390    99.980   104.390\n",
       "2     1990/12/21    104.39   109.070   109.130   103.730   109.130\n",
       "3     1990/12/24    109.13   113.570   114.550   109.130   114.550\n",
       "4     1990/12/25    114.55   120.090   120.250   114.550   120.250\n",
       "...          ...       ...       ...       ...       ...       ...\n",
       "8468   2025/8/25  3825.759  3848.163  3883.562  3839.972  3883.562\n",
       "8469   2025/8/26  3883.562  3871.471  3888.599  3859.758  3868.382\n",
       "8470   2025/8/27  3868.382  3869.612  3887.198  3800.350  3800.350\n",
       "8471   2025/8/28   3800.35  3796.711  3845.087  3761.422  3843.597\n",
       "8472   2025/8/29  3843.597  3842.823  3867.606  3839.206  3857.927\n",
       "\n",
       "[8473 rows x 6 columns]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "             Day  Preclose      Open   Highest    Lowest     Close\n",
      "0     1990/12/19              96.050    99.980    95.790    99.980\n",
      "1     1990/12/20     99.98   104.300   104.390    99.980   104.390\n",
      "2     1990/12/21    104.39   109.070   109.130   103.730   109.130\n",
      "3     1990/12/24    109.13   113.570   114.550   109.130   114.550\n",
      "4     1990/12/25    114.55   120.090   120.250   114.550   120.250\n",
      "...          ...       ...       ...       ...       ...       ...\n",
      "8468   2025/8/25  3825.759  3848.163  3883.562  3839.972  3883.562\n",
      "8469   2025/8/26  3883.562  3871.471  3888.599  3859.758  3868.382\n",
      "8470   2025/8/27  3868.382  3869.612  3887.198  3800.350  3800.350\n",
      "8471   2025/8/28   3800.35  3796.711  3845.087  3761.422  3843.597\n",
      "8472   2025/8/29  3843.597  3842.823  3867.606  3839.206  3857.927\n",
      "\n",
      "[8473 rows x 6 columns]\n"
     ]
    }
   ],
   "source": [
    "data = pd.read_csv('D:\\python course/000001.csv') # 这一句是导入CSV文件的命令\n",
    "data\n",
    "print(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "9c990deb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.frame.DataFrame"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(data)#数据框 dataframe 是金融数据处理中最常用的数据格式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b6a57f38",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Index(['Day', 'Preclose', 'Open', 'Highest', 'Lowest', 'Close'], dtype='object')\n"
     ]
    }
   ],
   "source": [
    "print(data.columns)#打印数据框的列名"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "94a3e6f1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Day' 'Preclose' 'Open' 'Highest' 'Lowest' 'Close']\n"
     ]
    }
   ],
   "source": [
    "print(data.columns.values)#打印数据框的列名"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "f5d99eb2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "Day",
         "rawType": "object",
         "type": "string"
        }
       ],
       "ref": "82af0ffc-3378-4aba-b5a7-52e9f6016d40",
       "rows": [
        [
         "0",
         "1990/12/19"
        ],
        [
         "1",
         "1990/12/20"
        ],
        [
         "2",
         "1990/12/21"
        ],
        [
         "3",
         "1990/12/24"
        ],
        [
         "4",
         "1990/12/25"
        ],
        [
         "5",
         "1990/12/26"
        ],
        [
         "6",
         "1990/12/27"
        ],
        [
         "7",
         "1990/12/28"
        ],
        [
         "8",
         "1990/12/31"
        ],
        [
         "9",
         "1991/1/2"
        ],
        [
         "10",
         "1991/1/3"
        ],
        [
         "11",
         "1991/1/4"
        ],
        [
         "12",
         "1991/1/7"
        ],
        [
         "13",
         "1991/1/8"
        ],
        [
         "14",
         "1991/1/9"
        ],
        [
         "15",
         "1991/1/10"
        ],
        [
         "16",
         "1991/1/11"
        ],
        [
         "17",
         "1991/1/14"
        ],
        [
         "18",
         "1991/1/15"
        ],
        [
         "19",
         "1991/1/16"
        ],
        [
         "20",
         "1991/1/17"
        ],
        [
         "21",
         "1991/1/18"
        ],
        [
         "22",
         "1991/1/21"
        ],
        [
         "23",
         "1991/1/22"
        ],
        [
         "24",
         "1991/1/23"
        ],
        [
         "25",
         "1991/1/24"
        ],
        [
         "26",
         "1991/1/25"
        ],
        [
         "27",
         "1991/1/28"
        ],
        [
         "28",
         "1991/1/29"
        ],
        [
         "29",
         "1991/1/30"
        ],
        [
         "30",
         "1991/1/31"
        ],
        [
         "31",
         "1991/2/1"
        ],
        [
         "32",
         "1991/2/4"
        ],
        [
         "33",
         "1991/2/5"
        ],
        [
         "34",
         "1991/2/6"
        ],
        [
         "35",
         "1991/2/7"
        ],
        [
         "36",
         "1991/2/8"
        ],
        [
         "37",
         "1991/2/11"
        ],
        [
         "38",
         "1991/2/12"
        ],
        [
         "39",
         "1991/2/13"
        ],
        [
         "40",
         "1991/2/14"
        ],
        [
         "41",
         "1991/2/19"
        ],
        [
         "42",
         "1991/2/20"
        ],
        [
         "43",
         "1991/2/21"
        ],
        [
         "44",
         "1991/2/22"
        ],
        [
         "45",
         "1991/2/25"
        ],
        [
         "46",
         "1991/2/26"
        ],
        [
         "47",
         "1991/2/27"
        ],
        [
         "48",
         "1991/2/28"
        ],
        [
         "49",
         "1991/3/1"
        ]
       ],
       "shape": {
        "columns": 1,
        "rows": 8473
       }
      },
      "text/plain": [
       "0       1990/12/19\n",
       "1       1990/12/20\n",
       "2       1990/12/21\n",
       "3       1990/12/24\n",
       "4       1990/12/25\n",
       "           ...    \n",
       "8468     2025/8/25\n",
       "8469     2025/8/26\n",
       "8470     2025/8/27\n",
       "8471     2025/8/28\n",
       "8472     2025/8/29\n",
       "Name: Day, Length: 8473, dtype: object"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['Day']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "dc9eeab1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "Day",
         "rawType": "object",
         "type": "string"
        }
       ],
       "ref": "d77ebb4b-1746-4daa-9004-d8d4b9f2d4c1",
       "rows": [
        [
         "0",
         "1990/12/19"
        ],
        [
         "1",
         "1990/12/20"
        ],
        [
         "2",
         "1990/12/21"
        ],
        [
         "3",
         "1990/12/24"
        ],
        [
         "4",
         "1990/12/25"
        ],
        [
         "5",
         "1990/12/26"
        ],
        [
         "6",
         "1990/12/27"
        ],
        [
         "7",
         "1990/12/28"
        ],
        [
         "8",
         "1990/12/31"
        ],
        [
         "9",
         "1991/1/2"
        ],
        [
         "10",
         "1991/1/3"
        ],
        [
         "11",
         "1991/1/4"
        ],
        [
         "12",
         "1991/1/7"
        ],
        [
         "13",
         "1991/1/8"
        ],
        [
         "14",
         "1991/1/9"
        ],
        [
         "15",
         "1991/1/10"
        ],
        [
         "16",
         "1991/1/11"
        ],
        [
         "17",
         "1991/1/14"
        ],
        [
         "18",
         "1991/1/15"
        ],
        [
         "19",
         "1991/1/16"
        ],
        [
         "20",
         "1991/1/17"
        ],
        [
         "21",
         "1991/1/18"
        ],
        [
         "22",
         "1991/1/21"
        ],
        [
         "23",
         "1991/1/22"
        ],
        [
         "24",
         "1991/1/23"
        ],
        [
         "25",
         "1991/1/24"
        ],
        [
         "26",
         "1991/1/25"
        ],
        [
         "27",
         "1991/1/28"
        ],
        [
         "28",
         "1991/1/29"
        ],
        [
         "29",
         "1991/1/30"
        ],
        [
         "30",
         "1991/1/31"
        ],
        [
         "31",
         "1991/2/1"
        ],
        [
         "32",
         "1991/2/4"
        ],
        [
         "33",
         "1991/2/5"
        ],
        [
         "34",
         "1991/2/6"
        ],
        [
         "35",
         "1991/2/7"
        ],
        [
         "36",
         "1991/2/8"
        ],
        [
         "37",
         "1991/2/11"
        ],
        [
         "38",
         "1991/2/12"
        ],
        [
         "39",
         "1991/2/13"
        ],
        [
         "40",
         "1991/2/14"
        ],
        [
         "41",
         "1991/2/19"
        ],
        [
         "42",
         "1991/2/20"
        ],
        [
         "43",
         "1991/2/21"
        ],
        [
         "44",
         "1991/2/22"
        ],
        [
         "45",
         "1991/2/25"
        ],
        [
         "46",
         "1991/2/26"
        ],
        [
         "47",
         "1991/2/27"
        ],
        [
         "48",
         "1991/2/28"
        ],
        [
         "49",
         "1991/3/1"
        ]
       ],
       "shape": {
        "columns": 1,
        "rows": 8473
       }
      },
      "text/plain": [
       "0       1990/12/19\n",
       "1       1990/12/20\n",
       "2       1990/12/21\n",
       "3       1990/12/24\n",
       "4       1990/12/25\n",
       "           ...    \n",
       "8468     2025/8/25\n",
       "8469     2025/8/26\n",
       "8470     2025/8/27\n",
       "8471     2025/8/28\n",
       "8472     2025/8/29\n",
       "Name: Day, Length: 8473, dtype: object"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.Day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "a0866655",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "Day",
         "rawType": "object",
         "type": "string"
        }
       ],
       "ref": "c0db923b-36a5-4757-ad6f-8dc1d697c76a",
       "rows": [
        [
         "0",
         "1990/12/19"
        ],
        [
         "1",
         "1990/12/20"
        ],
        [
         "2",
         "1990/12/21"
        ],
        [
         "3",
         "1990/12/24"
        ],
        [
         "4",
         "1990/12/25"
        ],
        [
         "5",
         "1990/12/26"
        ],
        [
         "6",
         "1990/12/27"
        ],
        [
         "7",
         "1990/12/28"
        ],
        [
         "8",
         "1990/12/31"
        ],
        [
         "9",
         "1991/1/2"
        ],
        [
         "10",
         "1991/1/3"
        ],
        [
         "11",
         "1991/1/4"
        ],
        [
         "12",
         "1991/1/7"
        ],
        [
         "13",
         "1991/1/8"
        ],
        [
         "14",
         "1991/1/9"
        ],
        [
         "15",
         "1991/1/10"
        ],
        [
         "16",
         "1991/1/11"
        ],
        [
         "17",
         "1991/1/14"
        ],
        [
         "18",
         "1991/1/15"
        ],
        [
         "19",
         "1991/1/16"
        ],
        [
         "20",
         "1991/1/17"
        ],
        [
         "21",
         "1991/1/18"
        ],
        [
         "22",
         "1991/1/21"
        ],
        [
         "23",
         "1991/1/22"
        ],
        [
         "24",
         "1991/1/23"
        ],
        [
         "25",
         "1991/1/24"
        ],
        [
         "26",
         "1991/1/25"
        ],
        [
         "27",
         "1991/1/28"
        ],
        [
         "28",
         "1991/1/29"
        ],
        [
         "29",
         "1991/1/30"
        ],
        [
         "30",
         "1991/1/31"
        ],
        [
         "31",
         "1991/2/1"
        ],
        [
         "32",
         "1991/2/4"
        ],
        [
         "33",
         "1991/2/5"
        ],
        [
         "34",
         "1991/2/6"
        ],
        [
         "35",
         "1991/2/7"
        ],
        [
         "36",
         "1991/2/8"
        ],
        [
         "37",
         "1991/2/11"
        ],
        [
         "38",
         "1991/2/12"
        ],
        [
         "39",
         "1991/2/13"
        ],
        [
         "40",
         "1991/2/14"
        ],
        [
         "41",
         "1991/2/19"
        ],
        [
         "42",
         "1991/2/20"
        ],
        [
         "43",
         "1991/2/21"
        ],
        [
         "44",
         "1991/2/22"
        ],
        [
         "45",
         "1991/2/25"
        ],
        [
         "46",
         "1991/2/26"
        ],
        [
         "47",
         "1991/2/27"
        ],
        [
         "48",
         "1991/2/28"
        ],
        [
         "49",
         "1991/3/1"
        ]
       ],
       "shape": {
        "columns": 1,
        "rows": 8473
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Day</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1990/12/19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1990/12/20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1990/12/21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1990/12/24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1990/12/25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8468</th>\n",
       "      <td>2025/8/25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8469</th>\n",
       "      <td>2025/8/26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8470</th>\n",
       "      <td>2025/8/27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8471</th>\n",
       "      <td>2025/8/28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8472</th>\n",
       "      <td>2025/8/29</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8473 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             Day\n",
       "0     1990/12/19\n",
       "1     1990/12/20\n",
       "2     1990/12/21\n",
       "3     1990/12/24\n",
       "4     1990/12/25\n",
       "...          ...\n",
       "8468   2025/8/25\n",
       "8469   2025/8/26\n",
       "8470   2025/8/27\n",
       "8471   2025/8/28\n",
       "8472   2025/8/29\n",
       "\n",
       "[8473 rows x 1 columns]"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[['Day']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "044d01ae",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.series.Series"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(data['Day'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "54d10e95",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.frame.DataFrame"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(data[['Day']])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bfe82403",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "Day",
         "rawType": "object",
         "type": "string"
        }
       ],
       "ref": "4456bb89-f9e6-466b-9c6f-19bc31b99dde",
       "rows": [
        [
         "0",
         "1990/12/19"
        ],
        [
         "1",
         "1990/12/20"
        ],
        [
         "2",
         "1990/12/21"
        ],
        [
         "3",
         "1990/12/24"
        ],
        [
         "4",
         "1990/12/25"
        ],
        [
         "5",
         "1990/12/26"
        ],
        [
         "6",
         "1990/12/27"
        ],
        [
         "7",
         "1990/12/28"
        ],
        [
         "8",
         "1990/12/31"
        ],
        [
         "9",
         "1991/1/2"
        ],
        [
         "10",
         "1991/1/3"
        ],
        [
         "11",
         "1991/1/4"
        ],
        [
         "12",
         "1991/1/7"
        ],
        [
         "13",
         "1991/1/8"
        ],
        [
         "14",
         "1991/1/9"
        ],
        [
         "15",
         "1991/1/10"
        ],
        [
         "16",
         "1991/1/11"
        ],
        [
         "17",
         "1991/1/14"
        ],
        [
         "18",
         "1991/1/15"
        ],
        [
         "19",
         "1991/1/16"
        ],
        [
         "20",
         "1991/1/17"
        ],
        [
         "21",
         "1991/1/18"
        ],
        [
         "22",
         "1991/1/21"
        ],
        [
         "23",
         "1991/1/22"
        ],
        [
         "24",
         "1991/1/23"
        ],
        [
         "25",
         "1991/1/24"
        ],
        [
         "26",
         "1991/1/25"
        ],
        [
         "27",
         "1991/1/28"
        ],
        [
         "28",
         "1991/1/29"
        ],
        [
         "29",
         "1991/1/30"
        ],
        [
         "30",
         "1991/1/31"
        ],
        [
         "31",
         "1991/2/1"
        ],
        [
         "32",
         "1991/2/4"
        ],
        [
         "33",
         "1991/2/5"
        ],
        [
         "34",
         "1991/2/6"
        ],
        [
         "35",
         "1991/2/7"
        ],
        [
         "36",
         "1991/2/8"
        ],
        [
         "37",
         "1991/2/11"
        ],
        [
         "38",
         "1991/2/12"
        ],
        [
         "39",
         "1991/2/13"
        ],
        [
         "40",
         "1991/2/14"
        ],
        [
         "41",
         "1991/2/19"
        ],
        [
         "42",
         "1991/2/20"
        ],
        [
         "43",
         "1991/2/21"
        ],
        [
         "44",
         "1991/2/22"
        ],
        [
         "45",
         "1991/2/25"
        ],
        [
         "46",
         "1991/2/26"
        ],
        [
         "47",
         "1991/2/27"
        ],
        [
         "48",
         "1991/2/28"
        ],
        [
         "49",
         "1991/3/1"
        ]
       ],
       "shape": {
        "columns": 1,
        "rows": 8473
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Day</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1990/12/19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1990/12/20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1990/12/21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1990/12/24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1990/12/25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8468</th>\n",
       "      <td>2025/8/25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8469</th>\n",
       "      <td>2025/8/26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8470</th>\n",
       "      <td>2025/8/27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8471</th>\n",
       "      <td>2025/8/28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8472</th>\n",
       "      <td>2025/8/29</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8473 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             Day\n",
       "0     1990/12/19\n",
       "1     1990/12/20\n",
       "2     1990/12/21\n",
       "3     1990/12/24\n",
       "4     1990/12/25\n",
       "...          ...\n",
       "8468   2025/8/25\n",
       "8469   2025/8/26\n",
       "8470   2025/8/27\n",
       "8471   2025/8/28\n",
       "8472   2025/8/29\n",
       "\n",
       "[8473 rows x 1 columns]"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[['Day']]#选择单列数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "bd676142",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "Day",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Close",
         "rawType": "float64",
         "type": "float"
        }
       ],
       "ref": "a46adaf8-cdc3-4608-b71e-77c83d493a33",
       "rows": [
        [
         "0",
         "1990/12/19",
         "99.98"
        ],
        [
         "1",
         "1990/12/20",
         "104.39"
        ],
        [
         "2",
         "1990/12/21",
         "109.13"
        ],
        [
         "3",
         "1990/12/24",
         "114.55"
        ],
        [
         "4",
         "1990/12/25",
         "120.25"
        ],
        [
         "5",
         "1990/12/26",
         "125.27"
        ],
        [
         "6",
         "1990/12/27",
         "125.28"
        ],
        [
         "7",
         "1990/12/28",
         "126.45"
        ],
        [
         "8",
         "1990/12/31",
         "127.61"
        ],
        [
         "9",
         "1991/1/2",
         "128.84"
        ],
        [
         "10",
         "1991/1/3",
         "130.14"
        ],
        [
         "11",
         "1991/1/4",
         "131.44"
        ],
        [
         "12",
         "1991/1/7",
         "132.06"
        ],
        [
         "13",
         "1991/1/8",
         "132.68"
        ],
        [
         "14",
         "1991/1/9",
         "133.34"
        ],
        [
         "15",
         "1991/1/10",
         "133.97"
        ],
        [
         "16",
         "1991/1/11",
         "134.6"
        ],
        [
         "17",
         "1991/1/14",
         "134.67"
        ],
        [
         "18",
         "1991/1/15",
         "134.74"
        ],
        [
         "19",
         "1991/1/16",
         "134.24"
        ],
        [
         "20",
         "1991/1/17",
         "134.25"
        ],
        [
         "21",
         "1991/1/18",
         "134.24"
        ],
        [
         "22",
         "1991/1/21",
         "134.24"
        ],
        [
         "23",
         "1991/1/22",
         "133.72"
        ],
        [
         "24",
         "1991/1/23",
         "133.17"
        ],
        [
         "25",
         "1991/1/24",
         "132.61"
        ],
        [
         "26",
         "1991/1/25",
         "132.05"
        ],
        [
         "27",
         "1991/1/28",
         "131.46"
        ],
        [
         "28",
         "1991/1/29",
         "130.95"
        ],
        [
         "29",
         "1991/1/30",
         "130.44"
        ],
        [
         "30",
         "1991/1/31",
         "129.97"
        ],
        [
         "31",
         "1991/2/1",
         "129.51"
        ],
        [
         "32",
         "1991/2/4",
         "129.05"
        ],
        [
         "33",
         "1991/2/5",
         "128.58"
        ],
        [
         "34",
         "1991/2/6",
         "129.14"
        ],
        [
         "35",
         "1991/2/7",
         "129.79"
        ],
        [
         "36",
         "1991/2/8",
         "130.38"
        ],
        [
         "37",
         "1991/2/11",
         "130.97"
        ],
        [
         "38",
         "1991/2/12",
         "131.35"
        ],
        [
         "39",
         "1991/2/13",
         "131.92"
        ],
        [
         "40",
         "1991/2/14",
         "132.53"
        ],
        [
         "41",
         "1991/2/19",
         "133.13"
        ],
        [
         "42",
         "1991/2/20",
         "133.67"
        ],
        [
         "43",
         "1991/2/21",
         "134.28"
        ],
        [
         "44",
         "1991/2/22",
         "134.87"
        ],
        [
         "45",
         "1991/2/25",
         "134.4"
        ],
        [
         "46",
         "1991/2/26",
         "133.93"
        ],
        [
         "47",
         "1991/2/27",
         "133.47"
        ],
        [
         "48",
         "1991/2/28",
         "133.01"
        ],
        [
         "49",
         "1991/3/1",
         "132.53"
        ]
       ],
       "shape": {
        "columns": 2,
        "rows": 8473
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Day</th>\n",
       "      <th>Close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1990/12/19</td>\n",
       "      <td>99.980</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1990/12/20</td>\n",
       "      <td>104.390</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1990/12/21</td>\n",
       "      <td>109.130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1990/12/24</td>\n",
       "      <td>114.550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1990/12/25</td>\n",
       "      <td>120.250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8468</th>\n",
       "      <td>2025/8/25</td>\n",
       "      <td>3883.562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8469</th>\n",
       "      <td>2025/8/26</td>\n",
       "      <td>3868.382</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8470</th>\n",
       "      <td>2025/8/27</td>\n",
       "      <td>3800.350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8471</th>\n",
       "      <td>2025/8/28</td>\n",
       "      <td>3843.597</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8472</th>\n",
       "      <td>2025/8/29</td>\n",
       "      <td>3857.927</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8473 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             Day     Close\n",
       "0     1990/12/19    99.980\n",
       "1     1990/12/20   104.390\n",
       "2     1990/12/21   109.130\n",
       "3     1990/12/24   114.550\n",
       "4     1990/12/25   120.250\n",
       "...          ...       ...\n",
       "8468   2025/8/25  3883.562\n",
       "8469   2025/8/26  3868.382\n",
       "8470   2025/8/27  3800.350\n",
       "8471   2025/8/28  3843.597\n",
       "8472   2025/8/29  3857.927\n",
       "\n",
       "[8473 rows x 2 columns]"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[['Day','Close']]#选择多列数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "7a4d0832",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "Day",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Preclose",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Open",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Highest",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Lowest",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Close",
         "rawType": "float64",
         "type": "float"
        }
       ],
       "ref": "063b99c8-80fa-4afe-b17c-866f8c63f1d2",
       "rows": [
        [
         "0",
         "1990/12/19",
         "        ",
         "96.05",
         "99.98",
         "95.79",
         "99.98"
        ],
        [
         "1",
         "1990/12/20",
         "99.98",
         "104.3",
         "104.39",
         "99.98",
         "104.39"
        ],
        [
         "2",
         "1990/12/21",
         "104.39",
         "109.07",
         "109.13",
         "103.73",
         "109.13"
        ],
        [
         "3",
         "1990/12/24",
         "109.13",
         "113.57",
         "114.55",
         "109.13",
         "114.55"
        ],
        [
         "4",
         "1990/12/25",
         "114.55",
         "120.09",
         "120.25",
         "114.55",
         "120.25"
        ],
        [
         "5",
         "1990/12/26",
         "120.25",
         "125.27",
         "125.27",
         "120.25",
         "125.27"
        ],
        [
         "6",
         "1990/12/27",
         "125.27",
         "125.27",
         "125.28",
         "125.27",
         "125.28"
        ]
       ],
       "shape": {
        "columns": 6,
        "rows": 7
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Day</th>\n",
       "      <th>Preclose</th>\n",
       "      <th>Open</th>\n",
       "      <th>Highest</th>\n",
       "      <th>Lowest</th>\n",
       "      <th>Close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1990/12/19</td>\n",
       "      <td></td>\n",
       "      <td>96.05</td>\n",
       "      <td>99.98</td>\n",
       "      <td>95.79</td>\n",
       "      <td>99.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1990/12/20</td>\n",
       "      <td>99.98</td>\n",
       "      <td>104.30</td>\n",
       "      <td>104.39</td>\n",
       "      <td>99.98</td>\n",
       "      <td>104.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1990/12/21</td>\n",
       "      <td>104.39</td>\n",
       "      <td>109.07</td>\n",
       "      <td>109.13</td>\n",
       "      <td>103.73</td>\n",
       "      <td>109.13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1990/12/24</td>\n",
       "      <td>109.13</td>\n",
       "      <td>113.57</td>\n",
       "      <td>114.55</td>\n",
       "      <td>109.13</td>\n",
       "      <td>114.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1990/12/25</td>\n",
       "      <td>114.55</td>\n",
       "      <td>120.09</td>\n",
       "      <td>120.25</td>\n",
       "      <td>114.55</td>\n",
       "      <td>120.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1990/12/26</td>\n",
       "      <td>120.25</td>\n",
       "      <td>125.27</td>\n",
       "      <td>125.27</td>\n",
       "      <td>120.25</td>\n",
       "      <td>125.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1990/12/27</td>\n",
       "      <td>125.27</td>\n",
       "      <td>125.27</td>\n",
       "      <td>125.28</td>\n",
       "      <td>125.27</td>\n",
       "      <td>125.28</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          Day  Preclose    Open  Highest  Lowest   Close\n",
       "0  1990/12/19             96.05    99.98   95.79   99.98\n",
       "1  1990/12/20     99.98  104.30   104.39   99.98  104.39\n",
       "2  1990/12/21    104.39  109.07   109.13  103.73  109.13\n",
       "3  1990/12/24    109.13  113.57   114.55  109.13  114.55\n",
       "4  1990/12/25    114.55  120.09   120.25  114.55  120.25\n",
       "5  1990/12/26    120.25  125.27   125.27  120.25  125.27\n",
       "6  1990/12/27    125.27  125.27   125.28  125.27  125.28"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 该代码用于选择data数据框中的第0行到第6行（共7行），即通过切片操作选取前7行数据。\n",
    "data[0:7]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "d7e11017",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "Day",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Preclose",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Open",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Highest",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Lowest",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Close",
         "rawType": "float64",
         "type": "float"
        }
       ],
       "ref": "9b0fa8a5-e5fd-41e5-ae6d-1a4e01ca310a",
       "rows": [
        [
         "0",
         "1990/12/19",
         "        ",
         "96.05",
         "99.98",
         "95.79",
         "99.98"
        ],
        [
         "1",
         "1990/12/20",
         "99.98",
         "104.3",
         "104.39",
         "99.98",
         "104.39"
        ],
        [
         "2",
         "1990/12/21",
         "104.39",
         "109.07",
         "109.13",
         "103.73",
         "109.13"
        ],
        [
         "3",
         "1990/12/24",
         "109.13",
         "113.57",
         "114.55",
         "109.13",
         "114.55"
        ],
        [
         "4",
         "1990/12/25",
         "114.55",
         "120.09",
         "120.25",
         "114.55",
         "120.25"
        ]
       ],
       "shape": {
        "columns": 6,
        "rows": 5
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Day</th>\n",
       "      <th>Preclose</th>\n",
       "      <th>Open</th>\n",
       "      <th>Highest</th>\n",
       "      <th>Lowest</th>\n",
       "      <th>Close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1990/12/19</td>\n",
       "      <td></td>\n",
       "      <td>96.05</td>\n",
       "      <td>99.98</td>\n",
       "      <td>95.79</td>\n",
       "      <td>99.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1990/12/20</td>\n",
       "      <td>99.98</td>\n",
       "      <td>104.30</td>\n",
       "      <td>104.39</td>\n",
       "      <td>99.98</td>\n",
       "      <td>104.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1990/12/21</td>\n",
       "      <td>104.39</td>\n",
       "      <td>109.07</td>\n",
       "      <td>109.13</td>\n",
       "      <td>103.73</td>\n",
       "      <td>109.13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1990/12/24</td>\n",
       "      <td>109.13</td>\n",
       "      <td>113.57</td>\n",
       "      <td>114.55</td>\n",
       "      <td>109.13</td>\n",
       "      <td>114.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1990/12/25</td>\n",
       "      <td>114.55</td>\n",
       "      <td>120.09</td>\n",
       "      <td>120.25</td>\n",
       "      <td>114.55</td>\n",
       "      <td>120.25</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          Day  Preclose    Open  Highest  Lowest   Close\n",
       "0  1990/12/19             96.05    99.98   95.79   99.98\n",
       "1  1990/12/20     99.98  104.30   104.39   99.98  104.39\n",
       "2  1990/12/21    104.39  109.07   109.13  103.73  109.13\n",
       "3  1990/12/24    109.13  113.57   114.55  109.13  114.55\n",
       "4  1990/12/25    114.55  120.09   120.25  114.55  120.25"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 该代码使用 iloc 按照行号和列号进行数据选择。\n",
    "# data.iloc[0:5, 0:6] 表示选取 data 数据框的第 0 行到第 4 行（共 5 行），\n",
    "# 以及第 0 列到第 5 列（共 6 列）的数据。\n",
    "data.iloc[0:5,0:6] #按行列号访问"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "3236929b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.float64(109.07)"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 该代码通过 data.at[2, 'Open'] 实现了对 DataFrame 中第 2 行（索引为 2）且列名为 'Open' 的单元格的访问，返回该位置的具体数值。at 适用于通过“行标签+列标签”快速定位单个元素，效率较高。\n",
    "data.at[2,'Open'] # 按行索引，列名访问"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "3fd136e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "Open",
         "rawType": "float64",
         "type": "float"
        }
       ],
       "ref": "339d6e6a-71b4-44e9-82a5-f563a2e6591f",
       "rows": [
        [
         "2",
         "109.07"
        ]
       ],
       "shape": {
        "columns": 1,
        "rows": 1
       }
      },
      "text/plain": [
       "2    109.07\n",
       "Name: Open, dtype: float64"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用条件筛选来获取特定日期的开盘价\n",
    "# data[data['Day'] == \"1990/12/21\"] 先筛选出日期为\"1990/12/21\"的行\n",
    "# .Open 然后从筛选结果中提取'Open'列（开盘价）\n",
    "data[data['Day'] == \"1990/12/21\"].Open"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "8f4c2ad5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "Day",
         "rawType": "datetime64[ns]",
         "type": "datetime"
        },
        {
         "name": "Preclose",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Open",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Highest",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Lowest",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Close",
         "rawType": "float64",
         "type": "float"
        }
       ],
       "ref": "01a5dc70-d8bc-4149-8d33-a8f4e4420109",
       "rows": [
        [
         "0",
         "1990-12-19 00:00:00",
         "        ",
         "96.05",
         "99.98",
         "95.79",
         "99.98"
        ],
        [
         "1",
         "1990-12-20 00:00:00",
         "99.98",
         "104.3",
         "104.39",
         "99.98",
         "104.39"
        ],
        [
         "2",
         "1990-12-21 00:00:00",
         "104.39",
         "109.07",
         "109.13",
         "103.73",
         "109.13"
        ],
        [
         "3",
         "1990-12-24 00:00:00",
         "109.13",
         "113.57",
         "114.55",
         "109.13",
         "114.55"
        ],
        [
         "4",
         "1990-12-25 00:00:00",
         "114.55",
         "120.09",
         "120.25",
         "114.55",
         "120.25"
        ],
        [
         "5",
         "1990-12-26 00:00:00",
         "120.25",
         "125.27",
         "125.27",
         "120.25",
         "125.27"
        ],
        [
         "6",
         "1990-12-27 00:00:00",
         "125.27",
         "125.27",
         "125.28",
         "125.27",
         "125.28"
        ],
        [
         "7",
         "1990-12-28 00:00:00",
         "125.28",
         "126.39",
         "126.45",
         "125.28",
         "126.45"
        ],
        [
         "8",
         "1990-12-31 00:00:00",
         "126.45",
         "126.56",
         "127.61",
         "126.48",
         "127.61"
        ],
        [
         "9",
         "1991-01-02 00:00:00",
         "127.61",
         "127.61",
         "128.84",
         "127.61",
         "128.84"
        ],
        [
         "10",
         "1991-01-03 00:00:00",
         "128.84",
         "128.84",
         "130.14",
         "128.84",
         "130.14"
        ],
        [
         "11",
         "1991-01-04 00:00:00",
         "130.14",
         "131.27",
         "131.44",
         "130.14",
         "131.44"
        ],
        [
         "12",
         "1991-01-07 00:00:00",
         "131.44",
         "131.99",
         "132.06",
         "131.45",
         "132.06"
        ],
        [
         "13",
         "1991-01-08 00:00:00",
         "132.06",
         "132.62",
         "132.68",
         "132.06",
         "132.68"
        ],
        [
         "14",
         "1991-01-09 00:00:00",
         "132.68",
         "133.3",
         "133.34",
         "132.68",
         "133.34"
        ],
        [
         "15",
         "1991-01-10 00:00:00",
         "133.34",
         "133.93",
         "133.97",
         "133.34",
         "133.97"
        ],
        [
         "16",
         "1991-01-11 00:00:00",
         "133.97",
         "134.61",
         "134.61",
         "134.51",
         "134.6"
        ],
        [
         "17",
         "1991-01-14 00:00:00",
         "134.6",
         "134.11",
         "135.19",
         "134.11",
         "134.67"
        ],
        [
         "18",
         "1991-01-15 00:00:00",
         "134.67",
         "134.21",
         "134.74",
         "134.19",
         "134.74"
        ],
        [
         "19",
         "1991-01-16 00:00:00",
         "134.74",
         "134.19",
         "134.74",
         "134.14",
         "134.24"
        ],
        [
         "20",
         "1991-01-17 00:00:00",
         "134.24",
         "133.67",
         "134.25",
         "133.65",
         "134.25"
        ],
        [
         "21",
         "1991-01-18 00:00:00",
         "134.25",
         "133.7",
         "134.25",
         "133.67",
         "134.24"
        ],
        [
         "22",
         "1991-01-21 00:00:00",
         "134.24",
         "133.7",
         "134.24",
         "133.66",
         "134.24"
        ],
        [
         "23",
         "1991-01-22 00:00:00",
         "134.24",
         "133.72",
         "134.24",
         "133.66",
         "133.72"
        ],
        [
         "24",
         "1991-01-23 00:00:00",
         "133.72",
         "133.17",
         "133.72",
         "133.14",
         "133.17"
        ],
        [
         "25",
         "1991-01-24 00:00:00",
         "133.17",
         "132.61",
         "133.17",
         "132.57",
         "132.61"
        ],
        [
         "26",
         "1991-01-25 00:00:00",
         "132.61",
         "132.05",
         "132.07",
         "132.03",
         "132.05"
        ],
        [
         "27",
         "1991-01-28 00:00:00",
         "132.05",
         "131.46",
         "131.55",
         "131.46",
         "131.46"
        ],
        [
         "28",
         "1991-01-29 00:00:00",
         "131.46",
         "130.95",
         "130.97",
         "130.95",
         "130.95"
        ],
        [
         "29",
         "1991-01-30 00:00:00",
         "130.95",
         "130.44",
         "130.95",
         "130.41",
         "130.44"
        ],
        [
         "30",
         "1991-01-31 00:00:00",
         "130.44",
         "129.93",
         "130.46",
         "129.93",
         "129.97"
        ],
        [
         "31",
         "1991-02-01 00:00:00",
         "129.97",
         "129.5",
         "129.97",
         "129.45",
         "129.51"
        ],
        [
         "32",
         "1991-02-04 00:00:00",
         "129.51",
         "129.05",
         "129.58",
         "129.05",
         "129.05"
        ],
        [
         "33",
         "1991-02-05 00:00:00",
         "129.05",
         "128.56",
         "128.58",
         "128.53",
         "128.58"
        ],
        [
         "34",
         "1991-02-06 00:00:00",
         "128.58",
         "129.13",
         "129.15",
         "128.06",
         "129.14"
        ],
        [
         "35",
         "1991-02-07 00:00:00",
         "129.14",
         "129.74",
         "129.79",
         "129.14",
         "129.79"
        ],
        [
         "36",
         "1991-02-08 00:00:00",
         "129.79",
         "130.36",
         "130.39",
         "129.79",
         "130.38"
        ],
        [
         "37",
         "1991-02-11 00:00:00",
         "130.38",
         "130.92",
         "130.97",
         "130.39",
         "130.97"
        ],
        [
         "38",
         "1991-02-12 00:00:00",
         "130.97",
         "131.54",
         "131.56",
         "130.97",
         "131.35"
        ],
        [
         "39",
         "1991-02-13 00:00:00",
         "131.35",
         "131.93",
         "131.93",
         "131.35",
         "131.92"
        ],
        [
         "40",
         "1991-02-14 00:00:00",
         "131.92",
         "132.53",
         "132.53",
         "132.3",
         "132.53"
        ],
        [
         "41",
         "1991-02-19 00:00:00",
         "132.53",
         "133.12",
         "133.14",
         "133.08",
         "133.13"
        ],
        [
         "42",
         "1991-02-20 00:00:00",
         "133.13",
         "133.63",
         "133.67",
         "133.13",
         "133.67"
        ],
        [
         "43",
         "1991-02-21 00:00:00",
         "133.67",
         "134.24",
         "134.28",
         "133.67",
         "134.28"
        ],
        [
         "44",
         "1991-02-22 00:00:00",
         "134.28",
         "134.85",
         "134.87",
         "134.28",
         "134.87"
        ],
        [
         "45",
         "1991-02-25 00:00:00",
         "134.87",
         "134.37",
         "134.87",
         "134.33",
         "134.4"
        ],
        [
         "46",
         "1991-02-26 00:00:00",
         "134.4",
         "133.9",
         "134.44",
         "133.9",
         "133.93"
        ],
        [
         "47",
         "1991-02-27 00:00:00",
         "133.93",
         "133.44",
         "133.98",
         "133.44",
         "133.47"
        ],
        [
         "48",
         "1991-02-28 00:00:00",
         "133.47",
         "132.99",
         "133.52",
         "132.98",
         "133.01"
        ],
        [
         "49",
         "1991-03-01 00:00:00",
         "133.01",
         "132.53",
         "132.53",
         "132.47",
         "132.53"
        ]
       ],
       "shape": {
        "columns": 6,
        "rows": 8473
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Day</th>\n",
       "      <th>Preclose</th>\n",
       "      <th>Open</th>\n",
       "      <th>Highest</th>\n",
       "      <th>Lowest</th>\n",
       "      <th>Close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1990-12-19</td>\n",
       "      <td></td>\n",
       "      <td>96.050</td>\n",
       "      <td>99.980</td>\n",
       "      <td>95.790</td>\n",
       "      <td>99.980</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1990-12-20</td>\n",
       "      <td>99.98</td>\n",
       "      <td>104.300</td>\n",
       "      <td>104.390</td>\n",
       "      <td>99.980</td>\n",
       "      <td>104.390</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1990-12-21</td>\n",
       "      <td>104.39</td>\n",
       "      <td>109.070</td>\n",
       "      <td>109.130</td>\n",
       "      <td>103.730</td>\n",
       "      <td>109.130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1990-12-24</td>\n",
       "      <td>109.13</td>\n",
       "      <td>113.570</td>\n",
       "      <td>114.550</td>\n",
       "      <td>109.130</td>\n",
       "      <td>114.550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1990-12-25</td>\n",
       "      <td>114.55</td>\n",
       "      <td>120.090</td>\n",
       "      <td>120.250</td>\n",
       "      <td>114.550</td>\n",
       "      <td>120.250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8468</th>\n",
       "      <td>2025-08-25</td>\n",
       "      <td>3825.759</td>\n",
       "      <td>3848.163</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3839.972</td>\n",
       "      <td>3883.562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8469</th>\n",
       "      <td>2025-08-26</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3871.471</td>\n",
       "      <td>3888.599</td>\n",
       "      <td>3859.758</td>\n",
       "      <td>3868.382</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8470</th>\n",
       "      <td>2025-08-27</td>\n",
       "      <td>3868.382</td>\n",
       "      <td>3869.612</td>\n",
       "      <td>3887.198</td>\n",
       "      <td>3800.350</td>\n",
       "      <td>3800.350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8471</th>\n",
       "      <td>2025-08-28</td>\n",
       "      <td>3800.35</td>\n",
       "      <td>3796.711</td>\n",
       "      <td>3845.087</td>\n",
       "      <td>3761.422</td>\n",
       "      <td>3843.597</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8472</th>\n",
       "      <td>2025-08-29</td>\n",
       "      <td>3843.597</td>\n",
       "      <td>3842.823</td>\n",
       "      <td>3867.606</td>\n",
       "      <td>3839.206</td>\n",
       "      <td>3857.927</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8473 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            Day  Preclose      Open   Highest    Lowest     Close\n",
       "0    1990-12-19              96.050    99.980    95.790    99.980\n",
       "1    1990-12-20     99.98   104.300   104.390    99.980   104.390\n",
       "2    1990-12-21    104.39   109.070   109.130   103.730   109.130\n",
       "3    1990-12-24    109.13   113.570   114.550   109.130   114.550\n",
       "4    1990-12-25    114.55   120.090   120.250   114.550   120.250\n",
       "...         ...       ...       ...       ...       ...       ...\n",
       "8468 2025-08-25  3825.759  3848.163  3883.562  3839.972  3883.562\n",
       "8469 2025-08-26  3883.562  3871.471  3888.599  3859.758  3868.382\n",
       "8470 2025-08-27  3868.382  3869.612  3887.198  3800.350  3800.350\n",
       "8471 2025-08-28   3800.35  3796.711  3845.087  3761.422  3843.597\n",
       "8472 2025-08-29  3843.597  3842.823  3867.606  3839.206  3857.927\n",
       "\n",
       "[8473 rows x 6 columns]"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 将'Day'列从字符串格式转换为日期时间格式\n",
    "# pd.to_datetime() 函数用于将字符串转换为datetime对象\n",
    "# format='%Y/%m/%d' 指定了输入日期的格式：年/月/日（如1990/12/19）\n",
    "data['Day'] = pd.to_datetime(data['Day'],format = '%Y/%m/%d')\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "efae0b7c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 按照'Day'这一列对数据进行降序排序（即日期从新到旧）\n",
    "data = data.sort_values(by=['Day'], axis=0, ascending=False)\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "10d620f5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method sort_values in module pandas.core.frame:\n",
      "\n",
      "sort_values(\n",
      "    by: 'IndexLabel',\n",
      "    *,\n",
      "    axis: 'Axis' = 0,\n",
      "    ascending: 'bool | list[bool] | tuple[bool, ...]' = True,\n",
      "    inplace: 'bool' = False,\n",
      "    kind: 'SortKind' = 'quicksort',\n",
      "    na_position: 'str' = 'last',\n",
      "    ignore_index: 'bool' = False,\n",
      "    key: 'ValueKeyFunc | None' = None\n",
      ") -> 'DataFrame | None' method of pandas.core.frame.DataFrame instance\n",
      "    Sort by the values along either axis.\n",
      "\n",
      "    Parameters\n",
      "    ----------\n",
      "    by : str or list of str\n",
      "        Name or list of names to sort by.\n",
      "\n",
      "        - if `axis` is 0 or `'index'` then `by` may contain index\n",
      "          levels and/or column labels.\n",
      "        - if `axis` is 1 or `'columns'` then `by` may contain column\n",
      "          levels and/or index labels.\n",
      "    axis : \"{0 or 'index', 1 or 'columns'}\", default 0\n",
      "         Axis to be sorted.\n",
      "    ascending : bool or list of bool, default True\n",
      "         Sort ascending vs. descending. Specify list for multiple sort\n",
      "         orders.  If this is a list of bools, must match the length of\n",
      "         the by.\n",
      "    inplace : bool, default False\n",
      "         If True, perform operation in-place.\n",
      "    kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, default 'quicksort'\n",
      "         Choice of sorting algorithm. See also :func:`numpy.sort` for more\n",
      "         information. `mergesort` and `stable` are the only stable algorithms. For\n",
      "         DataFrames, this option is only applied when sorting on a single\n",
      "         column or label.\n",
      "    na_position : {'first', 'last'}, default 'last'\n",
      "         Puts NaNs at the beginning if `first`; `last` puts NaNs at the\n",
      "         end.\n",
      "    ignore_index : bool, default False\n",
      "         If True, the resulting axis will be labeled 0, 1, …, n - 1.\n",
      "    key : callable, optional\n",
      "        Apply the key function to the values\n",
      "        before sorting. This is similar to the `key` argument in the\n",
      "        builtin :meth:`sorted` function, with the notable difference that\n",
      "        this `key` function should be *vectorized*. It should expect a\n",
      "        ``Series`` and return a Series with the same shape as the input.\n",
      "        It will be applied to each column in `by` independently.\n",
      "\n",
      "    Returns\n",
      "    -------\n",
      "    DataFrame or None\n",
      "        DataFrame with sorted values or None if ``inplace=True``.\n",
      "\n",
      "    See Also\n",
      "    --------\n",
      "    DataFrame.sort_index : Sort a DataFrame by the index.\n",
      "    Series.sort_values : Similar method for a Series.\n",
      "\n",
      "    Examples\n",
      "    --------\n",
      "    >>> df = pd.DataFrame({\n",
      "    ...     'col1': ['A', 'A', 'B', np.nan, 'D', 'C'],\n",
      "    ...     'col2': [2, 1, 9, 8, 7, 4],\n",
      "    ...     'col3': [0, 1, 9, 4, 2, 3],\n",
      "    ...     'col4': ['a', 'B', 'c', 'D', 'e', 'F']\n",
      "    ... })\n",
      "    >>> df\n",
      "      col1  col2  col3 col4\n",
      "    0    A     2     0    a\n",
      "    1    A     1     1    B\n",
      "    2    B     9     9    c\n",
      "    3  NaN     8     4    D\n",
      "    4    D     7     2    e\n",
      "    5    C     4     3    F\n",
      "\n",
      "    Sort by col1\n",
      "\n",
      "    >>> df.sort_values(by=['col1'])\n",
      "      col1  col2  col3 col4\n",
      "    0    A     2     0    a\n",
      "    1    A     1     1    B\n",
      "    2    B     9     9    c\n",
      "    5    C     4     3    F\n",
      "    4    D     7     2    e\n",
      "    3  NaN     8     4    D\n",
      "\n",
      "    Sort by multiple columns\n",
      "\n",
      "    >>> df.sort_values(by=['col1', 'col2'])\n",
      "      col1  col2  col3 col4\n",
      "    1    A     1     1    B\n",
      "    0    A     2     0    a\n",
      "    2    B     9     9    c\n",
      "    5    C     4     3    F\n",
      "    4    D     7     2    e\n",
      "    3  NaN     8     4    D\n",
      "\n",
      "    Sort Descending\n",
      "\n",
      "    >>> df.sort_values(by='col1', ascending=False)\n",
      "      col1  col2  col3 col4\n",
      "    4    D     7     2    e\n",
      "    5    C     4     3    F\n",
      "    2    B     9     9    c\n",
      "    0    A     2     0    a\n",
      "    1    A     1     1    B\n",
      "    3  NaN     8     4    D\n",
      "\n",
      "    Putting NAs first\n",
      "\n",
      "    >>> df.sort_values(by='col1', ascending=False, na_position='first')\n",
      "      col1  col2  col3 col4\n",
      "    3  NaN     8     4    D\n",
      "    4    D     7     2    e\n",
      "    5    C     4     3    F\n",
      "    2    B     9     9    c\n",
      "    0    A     2     0    a\n",
      "    1    A     1     1    B\n",
      "\n",
      "    Sorting with a key function\n",
      "\n",
      "    >>> df.sort_values(by='col4', key=lambda col: col.str.lower())\n",
      "       col1  col2  col3 col4\n",
      "    0    A     2     0    a\n",
      "    1    A     1     1    B\n",
      "    2    B     9     9    c\n",
      "    3  NaN     8     4    D\n",
      "    4    D     7     2    e\n",
      "    5    C     4     3    F\n",
      "\n",
      "    Natural sort with the key argument,\n",
      "    using the `natsort <https://github.com/SethMMorton/natsort>` package.\n",
      "\n",
      "    >>> df = pd.DataFrame({\n",
      "    ...    \"time\": ['0hr', '128hr', '72hr', '48hr', '96hr'],\n",
      "    ...    \"value\": [10, 20, 30, 40, 50]\n",
      "    ... })\n",
      "    >>> df\n",
      "        time  value\n",
      "    0    0hr     10\n",
      "    1  128hr     20\n",
      "    2   72hr     30\n",
      "    3   48hr     40\n",
      "    4   96hr     50\n",
      "    >>> from natsort import index_natsorted\n",
      "    >>> df.sort_values(\n",
      "    ...     by=\"time\",\n",
      "    ...     key=lambda x: np.argsort(index_natsorted(df[\"time\"]))\n",
      "    ... )\n",
      "        time  value\n",
      "    0    0hr     10\n",
      "    3   48hr     40\n",
      "    2   72hr     30\n",
      "    4   96hr     50\n",
      "    1  128hr     20\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 使用help()函数查看sort_values方法的详细帮助信息\n",
    "# help()函数可以显示任何Python对象、函数或方法的文档字符串\n",
    "# 这对于初学者了解函数参数和用法非常有用\n",
    "help(data.sort_values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "5d22f578",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "Day",
         "rawType": "datetime64[ns]",
         "type": "datetime"
        },
        {
         "name": "Preclose",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Open",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Highest",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Lowest",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Close",
         "rawType": "float64",
         "type": "float"
        }
       ],
       "ref": "9783616e-9a81-4573-85b0-7b3986716867",
       "rows": [
        [
         "0",
         "1990-12-19 00:00:00",
         "        ",
         "96.05",
         "99.98",
         "95.79",
         "99.98"
        ],
        [
         "1",
         "1990-12-20 00:00:00",
         "99.98",
         "104.3",
         "104.39",
         "99.98",
         "104.39"
        ],
        [
         "2",
         "1990-12-21 00:00:00",
         "104.39",
         "109.07",
         "109.13",
         "103.73",
         "109.13"
        ],
        [
         "3",
         "1990-12-24 00:00:00",
         "109.13",
         "113.57",
         "114.55",
         "109.13",
         "114.55"
        ],
        [
         "4",
         "1990-12-25 00:00:00",
         "114.55",
         "120.09",
         "120.25",
         "114.55",
         "120.25"
        ],
        [
         "5",
         "1990-12-26 00:00:00",
         "120.25",
         "125.27",
         "125.27",
         "120.25",
         "125.27"
        ],
        [
         "6",
         "1990-12-27 00:00:00",
         "125.27",
         "125.27",
         "125.28",
         "125.27",
         "125.28"
        ],
        [
         "7",
         "1990-12-28 00:00:00",
         "125.28",
         "126.39",
         "126.45",
         "125.28",
         "126.45"
        ],
        [
         "8",
         "1990-12-31 00:00:00",
         "126.45",
         "126.56",
         "127.61",
         "126.48",
         "127.61"
        ],
        [
         "9",
         "1991-01-02 00:00:00",
         "127.61",
         "127.61",
         "128.84",
         "127.61",
         "128.84"
        ],
        [
         "10",
         "1991-01-03 00:00:00",
         "128.84",
         "128.84",
         "130.14",
         "128.84",
         "130.14"
        ],
        [
         "11",
         "1991-01-04 00:00:00",
         "130.14",
         "131.27",
         "131.44",
         "130.14",
         "131.44"
        ],
        [
         "12",
         "1991-01-07 00:00:00",
         "131.44",
         "131.99",
         "132.06",
         "131.45",
         "132.06"
        ],
        [
         "13",
         "1991-01-08 00:00:00",
         "132.06",
         "132.62",
         "132.68",
         "132.06",
         "132.68"
        ],
        [
         "14",
         "1991-01-09 00:00:00",
         "132.68",
         "133.3",
         "133.34",
         "132.68",
         "133.34"
        ],
        [
         "15",
         "1991-01-10 00:00:00",
         "133.34",
         "133.93",
         "133.97",
         "133.34",
         "133.97"
        ],
        [
         "16",
         "1991-01-11 00:00:00",
         "133.97",
         "134.61",
         "134.61",
         "134.51",
         "134.6"
        ],
        [
         "17",
         "1991-01-14 00:00:00",
         "134.6",
         "134.11",
         "135.19",
         "134.11",
         "134.67"
        ],
        [
         "18",
         "1991-01-15 00:00:00",
         "134.67",
         "134.21",
         "134.74",
         "134.19",
         "134.74"
        ],
        [
         "19",
         "1991-01-16 00:00:00",
         "134.74",
         "134.19",
         "134.74",
         "134.14",
         "134.24"
        ],
        [
         "20",
         "1991-01-17 00:00:00",
         "134.24",
         "133.67",
         "134.25",
         "133.65",
         "134.25"
        ],
        [
         "21",
         "1991-01-18 00:00:00",
         "134.25",
         "133.7",
         "134.25",
         "133.67",
         "134.24"
        ],
        [
         "22",
         "1991-01-21 00:00:00",
         "134.24",
         "133.7",
         "134.24",
         "133.66",
         "134.24"
        ],
        [
         "23",
         "1991-01-22 00:00:00",
         "134.24",
         "133.72",
         "134.24",
         "133.66",
         "133.72"
        ],
        [
         "24",
         "1991-01-23 00:00:00",
         "133.72",
         "133.17",
         "133.72",
         "133.14",
         "133.17"
        ],
        [
         "25",
         "1991-01-24 00:00:00",
         "133.17",
         "132.61",
         "133.17",
         "132.57",
         "132.61"
        ],
        [
         "26",
         "1991-01-25 00:00:00",
         "132.61",
         "132.05",
         "132.07",
         "132.03",
         "132.05"
        ],
        [
         "27",
         "1991-01-28 00:00:00",
         "132.05",
         "131.46",
         "131.55",
         "131.46",
         "131.46"
        ],
        [
         "28",
         "1991-01-29 00:00:00",
         "131.46",
         "130.95",
         "130.97",
         "130.95",
         "130.95"
        ],
        [
         "29",
         "1991-01-30 00:00:00",
         "130.95",
         "130.44",
         "130.95",
         "130.41",
         "130.44"
        ],
        [
         "30",
         "1991-01-31 00:00:00",
         "130.44",
         "129.93",
         "130.46",
         "129.93",
         "129.97"
        ],
        [
         "31",
         "1991-02-01 00:00:00",
         "129.97",
         "129.5",
         "129.97",
         "129.45",
         "129.51"
        ],
        [
         "32",
         "1991-02-04 00:00:00",
         "129.51",
         "129.05",
         "129.58",
         "129.05",
         "129.05"
        ],
        [
         "33",
         "1991-02-05 00:00:00",
         "129.05",
         "128.56",
         "128.58",
         "128.53",
         "128.58"
        ],
        [
         "34",
         "1991-02-06 00:00:00",
         "128.58",
         "129.13",
         "129.15",
         "128.06",
         "129.14"
        ],
        [
         "35",
         "1991-02-07 00:00:00",
         "129.14",
         "129.74",
         "129.79",
         "129.14",
         "129.79"
        ],
        [
         "36",
         "1991-02-08 00:00:00",
         "129.79",
         "130.36",
         "130.39",
         "129.79",
         "130.38"
        ],
        [
         "37",
         "1991-02-11 00:00:00",
         "130.38",
         "130.92",
         "130.97",
         "130.39",
         "130.97"
        ],
        [
         "38",
         "1991-02-12 00:00:00",
         "130.97",
         "131.54",
         "131.56",
         "130.97",
         "131.35"
        ],
        [
         "39",
         "1991-02-13 00:00:00",
         "131.35",
         "131.93",
         "131.93",
         "131.35",
         "131.92"
        ],
        [
         "40",
         "1991-02-14 00:00:00",
         "131.92",
         "132.53",
         "132.53",
         "132.3",
         "132.53"
        ],
        [
         "41",
         "1991-02-19 00:00:00",
         "132.53",
         "133.12",
         "133.14",
         "133.08",
         "133.13"
        ],
        [
         "42",
         "1991-02-20 00:00:00",
         "133.13",
         "133.63",
         "133.67",
         "133.13",
         "133.67"
        ],
        [
         "43",
         "1991-02-21 00:00:00",
         "133.67",
         "134.24",
         "134.28",
         "133.67",
         "134.28"
        ],
        [
         "44",
         "1991-02-22 00:00:00",
         "134.28",
         "134.85",
         "134.87",
         "134.28",
         "134.87"
        ],
        [
         "45",
         "1991-02-25 00:00:00",
         "134.87",
         "134.37",
         "134.87",
         "134.33",
         "134.4"
        ],
        [
         "46",
         "1991-02-26 00:00:00",
         "134.4",
         "133.9",
         "134.44",
         "133.9",
         "133.93"
        ],
        [
         "47",
         "1991-02-27 00:00:00",
         "133.93",
         "133.44",
         "133.98",
         "133.44",
         "133.47"
        ],
        [
         "48",
         "1991-02-28 00:00:00",
         "133.47",
         "132.99",
         "133.52",
         "132.98",
         "133.01"
        ],
        [
         "49",
         "1991-03-01 00:00:00",
         "133.01",
         "132.53",
         "132.53",
         "132.47",
         "132.53"
        ]
       ],
       "shape": {
        "columns": 6,
        "rows": 8473
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Day</th>\n",
       "      <th>Preclose</th>\n",
       "      <th>Open</th>\n",
       "      <th>Highest</th>\n",
       "      <th>Lowest</th>\n",
       "      <th>Close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1990-12-19</td>\n",
       "      <td></td>\n",
       "      <td>96.050</td>\n",
       "      <td>99.980</td>\n",
       "      <td>95.790</td>\n",
       "      <td>99.980</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1990-12-20</td>\n",
       "      <td>99.98</td>\n",
       "      <td>104.300</td>\n",
       "      <td>104.390</td>\n",
       "      <td>99.980</td>\n",
       "      <td>104.390</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1990-12-21</td>\n",
       "      <td>104.39</td>\n",
       "      <td>109.070</td>\n",
       "      <td>109.130</td>\n",
       "      <td>103.730</td>\n",
       "      <td>109.130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1990-12-24</td>\n",
       "      <td>109.13</td>\n",
       "      <td>113.570</td>\n",
       "      <td>114.550</td>\n",
       "      <td>109.130</td>\n",
       "      <td>114.550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1990-12-25</td>\n",
       "      <td>114.55</td>\n",
       "      <td>120.090</td>\n",
       "      <td>120.250</td>\n",
       "      <td>114.550</td>\n",
       "      <td>120.250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8468</th>\n",
       "      <td>2025-08-25</td>\n",
       "      <td>3825.759</td>\n",
       "      <td>3848.163</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3839.972</td>\n",
       "      <td>3883.562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8469</th>\n",
       "      <td>2025-08-26</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3871.471</td>\n",
       "      <td>3888.599</td>\n",
       "      <td>3859.758</td>\n",
       "      <td>3868.382</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8470</th>\n",
       "      <td>2025-08-27</td>\n",
       "      <td>3868.382</td>\n",
       "      <td>3869.612</td>\n",
       "      <td>3887.198</td>\n",
       "      <td>3800.350</td>\n",
       "      <td>3800.350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8471</th>\n",
       "      <td>2025-08-28</td>\n",
       "      <td>3800.35</td>\n",
       "      <td>3796.711</td>\n",
       "      <td>3845.087</td>\n",
       "      <td>3761.422</td>\n",
       "      <td>3843.597</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8472</th>\n",
       "      <td>2025-08-29</td>\n",
       "      <td>3843.597</td>\n",
       "      <td>3842.823</td>\n",
       "      <td>3867.606</td>\n",
       "      <td>3839.206</td>\n",
       "      <td>3857.927</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8473 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            Day  Preclose      Open   Highest    Lowest     Close\n",
       "0    1990-12-19              96.050    99.980    95.790    99.980\n",
       "1    1990-12-20     99.98   104.300   104.390    99.980   104.390\n",
       "2    1990-12-21    104.39   109.070   109.130   103.730   109.130\n",
       "3    1990-12-24    109.13   113.570   114.550   109.130   114.550\n",
       "4    1990-12-25    114.55   120.090   120.250   114.550   120.250\n",
       "...         ...       ...       ...       ...       ...       ...\n",
       "8468 2025-08-25  3825.759  3848.163  3883.562  3839.972  3883.562\n",
       "8469 2025-08-26  3883.562  3871.471  3888.599  3859.758  3868.382\n",
       "8470 2025-08-27  3868.382  3869.612  3887.198  3800.350  3800.350\n",
       "8471 2025-08-28   3800.35  3796.711  3845.087  3761.422  3843.597\n",
       "8472 2025-08-29  3843.597  3842.823  3867.606  3839.206  3857.927\n",
       "\n",
       "[8473 rows x 6 columns]"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 按照'Day'列对数据进行升序排序（即日期从旧到新）\n",
    "# by=['Day'] 指定按'Day'列排序\n",
    "# ascending=True 表示升序排列（False表示降序）\n",
    "data = data.sort_values(by=['Day'],ascending=True)\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "bbd3ad0b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "Day",
         "rawType": "datetime64[ns]",
         "type": "datetime"
        },
        {
         "name": "Preclose",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Open",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Highest",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Lowest",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Close",
         "rawType": "float64",
         "type": "float"
        }
       ],
       "ref": "55f6cab7-5d9f-4364-b784-e9d8fd0fa28a",
       "rows": [
        [
         "1990-12-19 00:00:00",
         "        ",
         "96.05",
         "99.98",
         "95.79",
         "99.98"
        ],
        [
         "1990-12-20 00:00:00",
         "99.98",
         "104.3",
         "104.39",
         "99.98",
         "104.39"
        ],
        [
         "1990-12-21 00:00:00",
         "104.39",
         "109.07",
         "109.13",
         "103.73",
         "109.13"
        ],
        [
         "1990-12-24 00:00:00",
         "109.13",
         "113.57",
         "114.55",
         "109.13",
         "114.55"
        ],
        [
         "1990-12-25 00:00:00",
         "114.55",
         "120.09",
         "120.25",
         "114.55",
         "120.25"
        ],
        [
         "1990-12-26 00:00:00",
         "120.25",
         "125.27",
         "125.27",
         "120.25",
         "125.27"
        ],
        [
         "1990-12-27 00:00:00",
         "125.27",
         "125.27",
         "125.28",
         "125.27",
         "125.28"
        ],
        [
         "1990-12-28 00:00:00",
         "125.28",
         "126.39",
         "126.45",
         "125.28",
         "126.45"
        ],
        [
         "1990-12-31 00:00:00",
         "126.45",
         "126.56",
         "127.61",
         "126.48",
         "127.61"
        ],
        [
         "1991-01-02 00:00:00",
         "127.61",
         "127.61",
         "128.84",
         "127.61",
         "128.84"
        ],
        [
         "1991-01-03 00:00:00",
         "128.84",
         "128.84",
         "130.14",
         "128.84",
         "130.14"
        ],
        [
         "1991-01-04 00:00:00",
         "130.14",
         "131.27",
         "131.44",
         "130.14",
         "131.44"
        ],
        [
         "1991-01-07 00:00:00",
         "131.44",
         "131.99",
         "132.06",
         "131.45",
         "132.06"
        ],
        [
         "1991-01-08 00:00:00",
         "132.06",
         "132.62",
         "132.68",
         "132.06",
         "132.68"
        ],
        [
         "1991-01-09 00:00:00",
         "132.68",
         "133.3",
         "133.34",
         "132.68",
         "133.34"
        ],
        [
         "1991-01-10 00:00:00",
         "133.34",
         "133.93",
         "133.97",
         "133.34",
         "133.97"
        ],
        [
         "1991-01-11 00:00:00",
         "133.97",
         "134.61",
         "134.61",
         "134.51",
         "134.6"
        ],
        [
         "1991-01-14 00:00:00",
         "134.6",
         "134.11",
         "135.19",
         "134.11",
         "134.67"
        ],
        [
         "1991-01-15 00:00:00",
         "134.67",
         "134.21",
         "134.74",
         "134.19",
         "134.74"
        ],
        [
         "1991-01-16 00:00:00",
         "134.74",
         "134.19",
         "134.74",
         "134.14",
         "134.24"
        ],
        [
         "1991-01-17 00:00:00",
         "134.24",
         "133.67",
         "134.25",
         "133.65",
         "134.25"
        ],
        [
         "1991-01-18 00:00:00",
         "134.25",
         "133.7",
         "134.25",
         "133.67",
         "134.24"
        ],
        [
         "1991-01-21 00:00:00",
         "134.24",
         "133.7",
         "134.24",
         "133.66",
         "134.24"
        ],
        [
         "1991-01-22 00:00:00",
         "134.24",
         "133.72",
         "134.24",
         "133.66",
         "133.72"
        ],
        [
         "1991-01-23 00:00:00",
         "133.72",
         "133.17",
         "133.72",
         "133.14",
         "133.17"
        ],
        [
         "1991-01-24 00:00:00",
         "133.17",
         "132.61",
         "133.17",
         "132.57",
         "132.61"
        ],
        [
         "1991-01-25 00:00:00",
         "132.61",
         "132.05",
         "132.07",
         "132.03",
         "132.05"
        ],
        [
         "1991-01-28 00:00:00",
         "132.05",
         "131.46",
         "131.55",
         "131.46",
         "131.46"
        ],
        [
         "1991-01-29 00:00:00",
         "131.46",
         "130.95",
         "130.97",
         "130.95",
         "130.95"
        ],
        [
         "1991-01-30 00:00:00",
         "130.95",
         "130.44",
         "130.95",
         "130.41",
         "130.44"
        ],
        [
         "1991-01-31 00:00:00",
         "130.44",
         "129.93",
         "130.46",
         "129.93",
         "129.97"
        ],
        [
         "1991-02-01 00:00:00",
         "129.97",
         "129.5",
         "129.97",
         "129.45",
         "129.51"
        ],
        [
         "1991-02-04 00:00:00",
         "129.51",
         "129.05",
         "129.58",
         "129.05",
         "129.05"
        ],
        [
         "1991-02-05 00:00:00",
         "129.05",
         "128.56",
         "128.58",
         "128.53",
         "128.58"
        ],
        [
         "1991-02-06 00:00:00",
         "128.58",
         "129.13",
         "129.15",
         "128.06",
         "129.14"
        ],
        [
         "1991-02-07 00:00:00",
         "129.14",
         "129.74",
         "129.79",
         "129.14",
         "129.79"
        ],
        [
         "1991-02-08 00:00:00",
         "129.79",
         "130.36",
         "130.39",
         "129.79",
         "130.38"
        ],
        [
         "1991-02-11 00:00:00",
         "130.38",
         "130.92",
         "130.97",
         "130.39",
         "130.97"
        ],
        [
         "1991-02-12 00:00:00",
         "130.97",
         "131.54",
         "131.56",
         "130.97",
         "131.35"
        ],
        [
         "1991-02-13 00:00:00",
         "131.35",
         "131.93",
         "131.93",
         "131.35",
         "131.92"
        ],
        [
         "1991-02-14 00:00:00",
         "131.92",
         "132.53",
         "132.53",
         "132.3",
         "132.53"
        ],
        [
         "1991-02-19 00:00:00",
         "132.53",
         "133.12",
         "133.14",
         "133.08",
         "133.13"
        ],
        [
         "1991-02-20 00:00:00",
         "133.13",
         "133.63",
         "133.67",
         "133.13",
         "133.67"
        ],
        [
         "1991-02-21 00:00:00",
         "133.67",
         "134.24",
         "134.28",
         "133.67",
         "134.28"
        ],
        [
         "1991-02-22 00:00:00",
         "134.28",
         "134.85",
         "134.87",
         "134.28",
         "134.87"
        ],
        [
         "1991-02-25 00:00:00",
         "134.87",
         "134.37",
         "134.87",
         "134.33",
         "134.4"
        ],
        [
         "1991-02-26 00:00:00",
         "134.4",
         "133.9",
         "134.44",
         "133.9",
         "133.93"
        ],
        [
         "1991-02-27 00:00:00",
         "133.93",
         "133.44",
         "133.98",
         "133.44",
         "133.47"
        ],
        [
         "1991-02-28 00:00:00",
         "133.47",
         "132.99",
         "133.52",
         "132.98",
         "133.01"
        ],
        [
         "1991-03-01 00:00:00",
         "133.01",
         "132.53",
         "132.53",
         "132.47",
         "132.53"
        ]
       ],
       "shape": {
        "columns": 5,
        "rows": 8473
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Preclose</th>\n",
       "      <th>Open</th>\n",
       "      <th>Highest</th>\n",
       "      <th>Lowest</th>\n",
       "      <th>Close</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Day</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1990-12-19</th>\n",
       "      <td></td>\n",
       "      <td>96.050</td>\n",
       "      <td>99.980</td>\n",
       "      <td>95.790</td>\n",
       "      <td>99.980</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1990-12-20</th>\n",
       "      <td>99.98</td>\n",
       "      <td>104.300</td>\n",
       "      <td>104.390</td>\n",
       "      <td>99.980</td>\n",
       "      <td>104.390</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1990-12-21</th>\n",
       "      <td>104.39</td>\n",
       "      <td>109.070</td>\n",
       "      <td>109.130</td>\n",
       "      <td>103.730</td>\n",
       "      <td>109.130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1990-12-24</th>\n",
       "      <td>109.13</td>\n",
       "      <td>113.570</td>\n",
       "      <td>114.550</td>\n",
       "      <td>109.130</td>\n",
       "      <td>114.550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1990-12-25</th>\n",
       "      <td>114.55</td>\n",
       "      <td>120.090</td>\n",
       "      <td>120.250</td>\n",
       "      <td>114.550</td>\n",
       "      <td>120.250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-25</th>\n",
       "      <td>3825.759</td>\n",
       "      <td>3848.163</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3839.972</td>\n",
       "      <td>3883.562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-26</th>\n",
       "      <td>3883.562</td>\n",
       "      <td>3871.471</td>\n",
       "      <td>3888.599</td>\n",
       "      <td>3859.758</td>\n",
       "      <td>3868.382</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-27</th>\n",
       "      <td>3868.382</td>\n",
       "      <td>3869.612</td>\n",
       "      <td>3887.198</td>\n",
       "      <td>3800.350</td>\n",
       "      <td>3800.350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-28</th>\n",
       "      <td>3800.35</td>\n",
       "      <td>3796.711</td>\n",
       "      <td>3845.087</td>\n",
       "      <td>3761.422</td>\n",
       "      <td>3843.597</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-29</th>\n",
       "      <td>3843.597</td>\n",
       "      <td>3842.823</td>\n",
       "      <td>3867.606</td>\n",
       "      <td>3839.206</td>\n",
       "      <td>3857.927</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8473 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            Preclose      Open   Highest    Lowest     Close\n",
       "Day                                                         \n",
       "1990-12-19              96.050    99.980    95.790    99.980\n",
       "1990-12-20     99.98   104.300   104.390    99.980   104.390\n",
       "1990-12-21    104.39   109.070   109.130   103.730   109.130\n",
       "1990-12-24    109.13   113.570   114.550   109.130   114.550\n",
       "1990-12-25    114.55   120.090   120.250   114.550   120.250\n",
       "...              ...       ...       ...       ...       ...\n",
       "2025-08-25  3825.759  3848.163  3883.562  3839.972  3883.562\n",
       "2025-08-26  3883.562  3871.471  3888.599  3859.758  3868.382\n",
       "2025-08-27  3868.382  3869.612  3887.198  3800.350  3800.350\n",
       "2025-08-28   3800.35  3796.711  3845.087  3761.422  3843.597\n",
       "2025-08-29  3843.597  3842.823  3867.606  3839.206  3857.927\n",
       "\n",
       "[8473 rows x 5 columns]"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 将'Day'列设置为数据框的索引\n",
    "# set_index() 函数用于将指定列设置为DataFrame的索引\n",
    "# inplace=True 表示直接在原数据框上进行修改，不创建新的数据框\n",
    "# 设置索引后，可以通过日期直接访问对应的行数据\n",
    "data.set_index('Day', inplace = True)\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "f57310eb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "Day",
         "rawType": "datetime64[ns]",
         "type": "datetime"
        },
        {
         "name": "Preclose",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Open",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Highest",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Lowest",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Close",
         "rawType": "float64",
         "type": "float"
        }
       ],
       "ref": "20347802-6240-41a2-8114-e4835f65ac1a",
       "rows": [
        [
         "1995-12-01 00:00:00",
         "641.14",
         "631.55",
         "639.49",
         "624.93",
         "633.81"
        ],
        [
         "1995-12-04 00:00:00",
         "633.81",
         "632.72",
         "635.73",
         "632.24",
         "634.92"
        ],
        [
         "1995-12-05 00:00:00",
         "634.92",
         "636.43",
         "638.76",
         "635.59",
         "637.22"
        ],
        [
         "1995-12-06 00:00:00",
         "637.22",
         "637.3",
         "637.32",
         "627.85",
         "628.43"
        ],
        [
         "1995-12-07 00:00:00",
         "628.43",
         "628.63",
         "632.37",
         "627.06",
         "631.84"
        ],
        [
         "1995-12-08 00:00:00",
         "631.84",
         "631.95",
         "643.36",
         "631.84",
         "636.78"
        ],
        [
         "1995-12-11 00:00:00",
         "636.78",
         "636.82",
         "639.29",
         "618.08",
         "619.26"
        ],
        [
         "1995-12-12 00:00:00",
         "619.26",
         "616.35",
         "633.93",
         "605.09",
         "629.45"
        ],
        [
         "1995-12-13 00:00:00",
         "629.45",
         "629.84",
         "631.02",
         "613.19",
         "613.8"
        ],
        [
         "1995-12-14 00:00:00",
         "613.8",
         "613.07",
         "617.86",
         "611.49",
         "614.75"
        ],
        [
         "1995-12-15 00:00:00",
         "614.75",
         "612.6",
         "612.61",
         "601.02",
         "603.89"
        ],
        [
         "1995-12-18 00:00:00",
         "603.89",
         "600.65",
         "600.65",
         "591.51",
         "592.14"
        ],
        [
         "1995-12-19 00:00:00",
         "592.14",
         "592.72",
         "596.35",
         "590.9",
         "592.06"
        ],
        [
         "1995-12-20 00:00:00",
         "592.06",
         "593.51",
         "601.1",
         "593.51",
         "601.04"
        ],
        [
         "1995-12-21 00:00:00",
         "601.04",
         "601.91",
         "606.69",
         "597.23",
         "597.43"
        ],
        [
         "1995-12-22 00:00:00",
         "597.43",
         "596.26",
         "599.71",
         "591.37",
         "594.24"
        ],
        [
         "1995-12-25 00:00:00",
         "594.24",
         "590.76",
         "590.76",
         "579.26",
         "580.03"
        ],
        [
         "1995-12-26 00:00:00",
         "580.03",
         "578.79",
         "580.38",
         "571.43",
         "572.22"
        ],
        [
         "1995-12-27 00:00:00",
         "572.22",
         "571.68",
         "573.87",
         "562.33",
         "570.4"
        ],
        [
         "1995-12-28 00:00:00",
         "570.4",
         "568.77",
         "569.19",
         "555.66",
         "556.82"
        ],
        [
         "1995-12-29 00:00:00",
         "556.82",
         "555.74",
         "561.61",
         "552.84",
         "555.29"
        ],
        [
         "1996-01-02 00:00:00",
         "555.29",
         "550.26",
         "550.26",
         "537.38",
         "537.87"
        ],
        [
         "1996-01-03 00:00:00",
         "537.87",
         "535.23",
         "542.74",
         "530.79",
         "542.42"
        ],
        [
         "1996-01-04 00:00:00",
         "542.42",
         "541.94",
         "558.94",
         "539.76",
         "558.76"
        ],
        [
         "1996-01-05 00:00:00",
         "558.76",
         "559.03",
         "561.36",
         "536.12",
         "536.37"
        ],
        [
         "1996-01-08 00:00:00",
         "536.37",
         "533.33",
         "540.04",
         "527.91",
         "539.17"
        ],
        [
         "1996-01-09 00:00:00",
         "539.17",
         "541.35",
         "559.64",
         "540.99",
         "558.62"
        ],
        [
         "1996-01-10 00:00:00",
         "558.62",
         "552.3",
         "552.31",
         "540.59",
         "547.62"
        ],
        [
         "1996-01-11 00:00:00",
         "547.62",
         "547.46",
         "552.56",
         "543.12",
         "545.64"
        ],
        [
         "1996-01-12 00:00:00",
         "545.64",
         "545.23",
         "549.76",
         "541.67",
         "547.11"
        ],
        [
         "1996-01-15 00:00:00",
         "547.11",
         "545.05",
         "551.91",
         "543.83",
         "551.04"
        ],
        [
         "1996-01-16 00:00:00",
         "551.04",
         "551.82",
         "554.9",
         "545.49",
         "547.76"
        ],
        [
         "1996-01-17 00:00:00",
         "547.76",
         "546.21",
         "548.57",
         "535.24",
         "537.31"
        ],
        [
         "1996-01-18 00:00:00",
         "537.31",
         "533.38",
         "533.41",
         "517.3",
         "517.63"
        ],
        [
         "1996-01-19 00:00:00",
         "517.63",
         "515.0",
         "523.59",
         "512.83",
         "523.51"
        ],
        [
         "1996-01-22 00:00:00",
         "523.51",
         "520.95",
         "521.0",
         "514.16",
         "516.46"
        ],
        [
         "1996-01-23 00:00:00",
         "516.46",
         "515.48",
         "522.41",
         "515.48",
         "519.6"
        ],
        [
         "1996-01-24 00:00:00",
         "519.6",
         "519.94",
         "524.33",
         "519.94",
         "522.63"
        ],
        [
         "1996-01-25 00:00:00",
         "522.63",
         "523.75",
         "538.96",
         "520.74",
         "521.37"
        ],
        [
         "1996-01-26 00:00:00",
         "521.37",
         "516.44",
         "527.07",
         "515.37",
         "525.57"
        ],
        [
         "1996-01-29 00:00:00",
         "525.57",
         "526.2",
         "530.17",
         "525.49",
         "529.14"
        ],
        [
         "1996-01-30 00:00:00",
         "529.14",
         "531.3",
         "532.65",
         "525.6",
         "532.57"
        ],
        [
         "1996-01-31 00:00:00",
         "532.57",
         "531.46",
         "538.11",
         "530.12",
         "537.35"
        ],
        [
         "1996-02-01 00:00:00",
         "537.35",
         "536.24",
         "537.17",
         "532.61",
         "536.68"
        ],
        [
         "1996-02-02 00:00:00",
         "536.68",
         "535.12",
         "536.04",
         "528.57",
         "536.04"
        ],
        [
         "1996-02-05 00:00:00",
         "536.04",
         "537.23",
         "537.27",
         "522.48",
         "522.85"
        ],
        [
         "1996-02-06 00:00:00",
         "522.85",
         "520.08",
         "522.67",
         "518.18",
         "520.69"
        ],
        [
         "1996-02-07 00:00:00",
         "520.69",
         "520.37",
         "524.72",
         "519.65",
         "524.3"
        ],
        [
         "1996-02-08 00:00:00",
         "524.3",
         "523.74",
         "524.65",
         "521.13",
         "521.86"
        ],
        [
         "1996-02-09 00:00:00",
         "521.86",
         "522.0",
         "525.43",
         "521.11",
         "525.41"
        ]
       ],
       "shape": {
        "columns": 5,
        "rows": 1070
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Preclose</th>\n",
       "      <th>Open</th>\n",
       "      <th>Highest</th>\n",
       "      <th>Lowest</th>\n",
       "      <th>Close</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Day</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1995-12-01</th>\n",
       "      <td>641.14</td>\n",
       "      <td>631.55</td>\n",
       "      <td>639.49</td>\n",
       "      <td>624.93</td>\n",
       "      <td>633.81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1995-12-04</th>\n",
       "      <td>633.81</td>\n",
       "      <td>632.72</td>\n",
       "      <td>635.73</td>\n",
       "      <td>632.24</td>\n",
       "      <td>634.92</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1995-12-05</th>\n",
       "      <td>634.92</td>\n",
       "      <td>636.43</td>\n",
       "      <td>638.76</td>\n",
       "      <td>635.59</td>\n",
       "      <td>637.22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1995-12-06</th>\n",
       "      <td>637.22</td>\n",
       "      <td>637.30</td>\n",
       "      <td>637.32</td>\n",
       "      <td>627.85</td>\n",
       "      <td>628.43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1995-12-07</th>\n",
       "      <td>628.43</td>\n",
       "      <td>628.63</td>\n",
       "      <td>632.37</td>\n",
       "      <td>627.06</td>\n",
       "      <td>631.84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-04-24</th>\n",
       "      <td>1841.06</td>\n",
       "      <td>1844.69</td>\n",
       "      <td>1848.97</td>\n",
       "      <td>1827.17</td>\n",
       "      <td>1837.40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-04-25</th>\n",
       "      <td>1837.4</td>\n",
       "      <td>1838.05</td>\n",
       "      <td>1841.86</td>\n",
       "      <td>1815.63</td>\n",
       "      <td>1833.47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-04-26</th>\n",
       "      <td>1833.47</td>\n",
       "      <td>1835.67</td>\n",
       "      <td>1842.89</td>\n",
       "      <td>1826.39</td>\n",
       "      <td>1832.78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-04-27</th>\n",
       "      <td>1832.78</td>\n",
       "      <td>1835.60</td>\n",
       "      <td>1840.57</td>\n",
       "      <td>1803.58</td>\n",
       "      <td>1806.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-04-28</th>\n",
       "      <td>1806.83</td>\n",
       "      <td>1805.50</td>\n",
       "      <td>1836.33</td>\n",
       "      <td>1797.71</td>\n",
       "      <td>1836.32</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1070 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           Preclose     Open  Highest   Lowest    Close\n",
       "Day                                                    \n",
       "1995-12-01   641.14   631.55   639.49   624.93   633.81\n",
       "1995-12-04   633.81   632.72   635.73   632.24   634.92\n",
       "1995-12-05   634.92   636.43   638.76   635.59   637.22\n",
       "1995-12-06   637.22   637.30   637.32   627.85   628.43\n",
       "1995-12-07   628.43   628.63   632.37   627.06   631.84\n",
       "...             ...      ...      ...      ...      ...\n",
       "2000-04-24  1841.06  1844.69  1848.97  1827.17  1837.40\n",
       "2000-04-25   1837.4  1838.05  1841.86  1815.63  1833.47\n",
       "2000-04-26  1833.47  1835.67  1842.89  1826.39  1832.78\n",
       "2000-04-27  1832.78  1835.60  1840.57  1803.58  1806.83\n",
       "2000-04-28  1806.83  1805.50  1836.33  1797.71  1836.32\n",
       "\n",
       "[1070 rows x 5 columns]"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用时间范围筛选数据，获取1995年12月到2000年4月的数据\n",
    "# 当'Day'列被设置为索引后，可以直接使用日期范围进行筛选\n",
    "# '1995-12':'2000-04' 表示从1995年12月开始到2000年4月结束的时间范围\n",
    "# 这种筛选方式对于时间序列数据分析非常有用\n",
    "data['1995-12':'2000-04']"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "py3.13",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
